in reply to file merge problem
while (<F1>) { /(\w*) (\d*)/ ; $hash1{$1} = $2 ; }
This won't solve your problem, but it's worth pointing out that you should never use $1, $2, etc without checking that the match succeeded. If the match failed then you'll get the values from the previous successful match.
while (<F1>) { if (/(\w*) (\d*)/) { $hash1{$1} = $2; } else { warn "Invalid input line $.: $_\n"; } }
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: file merge problem
by Anonymous Monk on Dec 09, 2005 at 13:17 UTC |