basm101 has asked for the wisdom of the Perl Monks concerning the following question:
Is the problem that I can't use $2 and $5 from my pattern match in this way ? I tried assigning like this:open(INFILE,$infile) or die "Can't open $infile\n"; print "opened $infile\n";<STDIN>; while(<INFILE>){ if(/(\s+)(\d+)(\.)(\s+)([A-Z]{2})(\s+)([A-Z]{5})/){ # this matches certain lines in my data files $number++; print "$2=>$5\n"; # this works and prints my key and value tha +t I want $hash_codes{$2}=>$5;#useless } }
but no joy either. Please help !$key = $2; $value = $5; $hash{$key}=>$value;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Useless use of hash element in void context
by tachyon (Chancellor) on Sep 25, 2003 at 10:32 UTC | |
|
Re: Useless use of hash element in void context
by broquaint (Abbot) on Sep 25, 2003 at 10:32 UTC |