iphone has asked for the wisdom of the Perl Monks concerning the following question:
The following snippet when the loop ends, every key is associated with the data for the last line.There is only one array (@file_lines). All the hash values are references (\@file_lines) to that array.How to create an anonymous array for each line and store a reference to that array in the hash?
foreach my $plf (@plf_files) { chomp($plf); open my $match, '<',"$start_dir\\$plf" or die "could not open '$plf' $ +!"; my @file_lines = <$match>; $Hash_filenames{$plf}=\@file_lines; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to create an anonymous array for lines in a file and store a reference to that array in the hash
by kcott (Archbishop) on Oct 29, 2010 at 09:39 UTC | |
|
Re: How to create an anonymous array for lines in a file and store a reference to that array in the hash
by happy.barney (Friar) on Oct 29, 2010 at 06:35 UTC | |
|
Re: How to create an anonymous array for lines in a file and store a reference to that array in the hash
by Anonymous Monk on Oct 29, 2010 at 06:39 UTC | |
|
Re: How to create an anonymous array for lines in a file and store a reference to that array in the hash
by locked_user sundialsvc4 (Abbot) on Nov 01, 2010 at 19:33 UTC |