in reply to Re: create a hash by reading file
in thread create a hash by reading file
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
|
|---|