in reply to Slice of an array of an array
Or you can skip the variable altogether and use:push @ip_time, $entry;
Here is the complete example with the slices:push @ip_time, [ split /,/ ];
use strict; use Data::Dumper; my $entry; my @ip_time; $_= "a,b,c,d,e,f"; $entry = [ split /,/ ]; push @ip_time, $entry; # This does the whole array $_= "g,h,i,j,k,l"; push @ip_time, [ split /,/ ]; # This does the whole array push @ip_time, [@{[ split /,/ ]}[0,5]]; # Slice it! push @ip_time, [(split /,/ )[0,5]]; # This works, too $_= "m,n,o,p,q,r"; $entry = [ split /,/ ]; push @ip_time, [ @{$entry}[0,5] ]; print Dumper(@ip_time);
Update: fixed per wog's recommendation
It should work perfectly the first time! - toma
|
|---|