Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Need help with comparison code

by GotToBTru (Prior)
on Feb 02, 2011 at 18:16 UTC ( #885811=note: print w/replies, xml ) Need Help??

in reply to Need help with comparison code

You have opened both IN and OUT using the same mode. You probably mean:
open IN,'<',$matchfile or die "Could not open $matchfile\n"; open OUT,'>>,$outfile or die "Could not open $outfile\n";
Foreach syntax: foreach $var (@array)
For syntax: for (expression; condition; control)
I think you want to use two foreach commands here:
foreach my $file (@files) { foreach my $file2 (<IN>) {

Replies are listed 'Best First'.
Re^2: Need help with comparison code
by GrandFather (Sage) on Feb 03, 2011 at 03:52 UTC

    for/foreach (<$fh>) is generally a bad idea - it implies slurping the file and creating a list of lines internally. Better is to use a while (<$fh>) loop. In both cases the loop body handles things a line at a time, but while is a better semantic match and is likely to be much more memory (and possibly slightly more time) efficient.

    True laziness is hard work
Re^2: Need help with comparison code
by Gulliver (Monk) on Feb 02, 2011 at 18:52 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://885811]
[ambrus]: it now has two more people working there, and they're serving slower and more expensive.
[ambrus]: It used to be just a master cook who takes the order and puts the meat and eggs on the open grill plate table, and an assistant who removes them to a plate, adds the side dish, and gives the plate to the people in the queue, plus a cashier.
[ambrus]: Now it has five people instead of three, some sort of call number ticket system where people wait a lot for their food to get ready (it's the same kinds of grilled meat and fish on the same equipment, it won't actually fry slower),
[ambrus]: it's slow as hell, and the food costs significantly more.
[ambrus]: We no longer eat there.
LanX Everybody quotes it, some people read it, and a few people go by it
[ambrus]: LanX: why would I read it? isn't it a book for managers? I don't want to be a manager.
[ambrus]: I don't quote it either.
[erix]: it's really a software book, albeit about experiences from the 60s-80s. People haven't changed all that much though.
[erix]: a software project book, is probably more exact

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (16)
As of 2017-09-22 13:53 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (264 votes). Check out past polls.