in reply to How to copy an array to a hash?
Is the same as saying:my @array = (1, 2, 3, 4, 5, 6); my %hash = @array;
apart from not having an @array floating around in the second version of course. If you really want to get each non-empty line in your input file into a hash with a key that's generated by some iterative process, you want something likemy %hash = ( 1 => 2, 3 => 4, 5 => 6 );
open my $file, '<', $filename or die "Unable to open '$filename': $!"; my %edit; for (<$file>) { next if //; chomp; # Some code to get a $key with an appropriate value $edit{$key} = $_; } close $file;
|
|---|