The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You should make every progam begin with those two lines, unless you have a very good reason not to. It will force you to write cleaner code, helping you catch errors much quicker. Originally you did that, but somewhere along the road, it seemed, you dropped these lines.
This looks okay.
Because we use strict; we'll have to declare the array now. You did it right in the original code, but again, somewhere you strayed from the right path.
I really disagree with the exact wording of the error message here. As I've pointed out in the other threat. But bah. If this is how ya wanna put it, don't lemme stop ya!
I'm tempted to rewrite your loop so that it writes out lines as it reads them. There's really no point in keeping things in-memory, but I'll assume you have a reason for doing it this way. At any rate I'm getting rid of your $count variable. You don't really need it. This, too, has been pointed out in that other threat.
Or just push @lines, $_ while <$fh>;. Or, while we're at it. @lines = <$fh>;, as has been mentioned in... you know where. Anyway, I've moved this close statement up. There's no point in keeping the file handle open if you're not using it anymore anyway.
This looks okay.
I've rewritten your for loop to be more Perl-ish. This, too, has been demonstrated.
In reply to Re^7: difficulty in matching 2 fields of a same line
by muba
|
|