foreach (@v) { s/^\s+//; s/\s+$// }
push @{$data[$x]}, @v;
}
I'm getting an error : global variable @data requires explicit package name –
Not sure how to add "my" to it.
But I also don't understand this line of code,
- It's pushing the v element into data[x]. But how does the @ work. I understand the {} is used for hash.
mydeclares lexically-scoped variables. It doesn’t seem appropriate here, since there appear to be no new variables being named, unless@datais new, in which case themymust move:which is mostly useless as the lexical scope of
@datadisappears immediately, or more clearly and usefully:where
@datais in a slightly larger scope.perlreftutexplains@{...}. Withoutmy,means to take the
$xth element of the@dataarray, treat it as an array reference, and append@vto it.For example,