I'm guessing that the OP will want more than one key in his hash and therefore that the key names will exhibit a little more variety :)
#!/usr/bin/perl use strict; use warnings; open FILE, 'name_of_file' or die "Could not name_of_file for reading: $!\n"; my %hash; while (<FILE>) { if (/^(\w+)\s+([\w,=]*)$/) { $hash{$1} = $2; } }
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re^2: create a hash by reading file
by davorg
in thread create a hash by reading file
by s_gaurav1091
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |