in reply to foreach loop with array of arrays
$a and $b are special variables used in sort operations. Avoid using them anywhere else.
When you create the array, you're not making effective use of how for works. You don't even need that $a varaible. for defaults to putting things in the $_ variable, which is also what split defaults to using. Try:
for (@data) { push(@{$arrays}, [split(/ /)]); }
According to the above, you're making $arrays into a scalar that holds a referance to an array of arrays. When you dereferance that, you need to do:
foreach (@{ $arrays }) { . . . }
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
|
|---|