in reply to Hash Variable
my @vars = split(/\s*,\s*/,$rec);
Also, if you are only interested in $var3 for the hash, why work on the rest? Do something like:
If you could relay more info the format of the input and how you want to make use of the hash you might get more (better) suggestions.open (DATA, "<data.txt") or die "Can't open file $!\n"; @DATA = <DATA>; close (DATA); foreach $rec (@DATA) { chomp $rec; my @vars = split(/\s*,\s*/,$rec); # debug - you might want to join with '|' to see # whitespace in any vars print "VARS = " . join('|', @vars). "\n"; # now insert into the hash $var_hash{$vars[2]} = 'whatever'; }
best of luck
--telesto
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Hash Variable
by qball (Beadle) on Apr 06, 2001 at 00:31 UTC |