Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: read from two files at once?

by samtregar (Abbot)
on May 07, 2009 at 15:29 UTC ( #762639=note: print w/ replies, xml ) Need Help??


in reply to read from two files at once?

The problem with:

my ($in) = <CURR>;

Is that it puts <CURR> in list context. That causes it read all the lines in your file and then put the first one in $in! Instead you want:

my $in = <CURR>;

Which will read just one line. Reading from two files should work with something like:

open FILE1, "<", "file1.txt" or die $!; open FILE2, "<", "file1.txt" or die $!; while (!eof(FILE1) and !eof(FILE2)) { my $line1 = <FILE1>; my $line2 = <FILE2>; # ... }

-sam


Comment on Re: read from two files at once?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://762639]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2015-07-05 05:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls