in reply to Re: Re: Fill Arbitrary Array
in thread Fill array
The reason is you are printing an array reference as a string, which isn't going to work. A solution is to either use the venerable Data::Dumper or just deference it:ARRAY(0x80fe5a8) ARRAY(0x80fe5d2) ARRAY(0x80fe6f4)
I'm not sure how familiar you are with references, but here's a 5 second intro:# Data::Dumper saves the day again use Data::Dumper; print Dumper (\@name); # De-reference it and treat it as an array foreach my $row (@name) { print join (',', @$row),"\n"; }
my @array = qw[ 1 2 3 ]; my $array_ref = \@array; # Backslash makes a reference my @array_copy = @$array_ref; # @ de-references array reference $array[2] = 4; # Modifies @array directly print $array_ref->[2]; # Should be '4' now $array_ref->[1] = 5; # Modifies @array by reference print $array[1]; # Should be '5' $array_copy[1] = 6; # Modifies @array_copy, not @array print $array[1]; # Still '5'
|
|---|