in reply to Reading two text files parallelly...
open my $fh1, "<", $file1 or die "Cannot open file $file1: $!"; open my $fh1, "<", $file2 or die "Cannot open file $file2: $!";
Then, with while ( <F1>, <F2> ), you'd be reading a line from each file, not assinging it to anything, and entering the loop; $_ is only set while using while (<$file>). (I think.)
Really, that's quite a bad post you have there. Still, I've never tried something like this, so have a freebie from another newbie (and please try to ignore the awful variable names..):
use strict; use warnings; use 5.010; use autodie; open my $fh1, '<', 'file1'; open my $fh2, '<', 'file2'; while (my $test1 = <$fh1>, my $test2 = <$fh2>) { chomp($test1 //= ''); chomp($test2 //= ''); say "$test1, $test2"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading two text files parallelly...
by Marshall (Canon) on Nov 09, 2010 at 17:16 UTC | |
by Hugmeir (Sexton) on Nov 09, 2010 at 19:15 UTC | |
by Marshall (Canon) on Nov 11, 2010 at 16:48 UTC |