On 2010-11-04 10:16, Christian Stalp wrote:
Hello together,
I try to write some arrays into arrays using references.
my ($a, $b, $c, @mytemp, $myref, @my_globael_array)
while(<$myfile>)
{
($a, $b $c ) = getparameter();
@mytemp = ($a, $b, $c);
$myref = \...@mytemp;
push(@my_global_array, $myref);
}
But if I dismantle @my_global_array I get only the last entry, the last array.
Where is the problem?
There are a lot of issues with your code. One: the global array is
called my_globael_array, not my_global_array.
Try this:
#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
use Data::Dumper;
my @data; # global array
my $fname = "data.txt";
open my $fh, "<", $fname or die "$fname: $!";
while ( <$fh> ) {
push @data, [ split() ];
}
print Dumper( \...@data );
__END__
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/