|
Hi, I am new to perl. I have a text file that is formatted as show below....
John 82387
chris 39779
mary 39743
Joan 73973
Now i would like to create a hash with the number being they keys and the name being the value and i am trying to find the easiest way to do it ? is there any perl function that could simplify this
Thanks in advance for any help you can give
Regards,
Quest101
|
|
|
|
|
my %hash_table;
open(IN, "<ip1") or die "Couldn't open file for processing: $!";
while (<IN>) {
chomp;
( $hash_table{$key}, $key )= split(/ /,$_);
}
close IN;
foreach $key (keys %hash_table) {
print "$key = $hash_table{$key}\n";
}
|
|
|
|
|
|
|
// |