in reply to How to create an anonymous array for lines in a file and store a reference to that array in the hash

ow to create an anonymous array for each line and store a reference to that array in the hash?

Anonymous arrays are created with [ ], see perlref

But there is no need to do that, the problem you describe does not happen

my %hash; for my $eye ( 0 .. 2 ){ my @file_lines = map { "$eye$_" } 'a'..'c'; $hash{$eye} = \@file_lines; } use Data::Dumper; print Dumper( \%hash ); __END__ $VAR1 = { '1' => [ '1a', '1b', '1c' ], '0' => [ '0a', '0b', '0c' ], '2' => [ '2a', '2b', '2c' ] };
  • Comment on Re: How to create an anonymous array for lines in a file and store a reference to that array in the hash
  • Select or Download Code