The first thing you're doing wrong is using two loops. You definitely want a loop, but you want to read one line from each file in each pass of the loop. So get rid of the inner loop.
Next, you'll want to figure out when to end your loop. I'll assume that you want to end the loop only after you've completed both files.
So I'd suggest doing it more like this:
while (!eof(USER1) and !eof(USER2)) { my $line1 = <USER1>; my $line2 = <USER2>; . . . }
The condition in the while stops only when both files are finished. (See perldoc -f eof)
Update: s/feof/eof/g, thanks to Kenosis, who generously thought I meant eof, when it was just me mistaking C for perl. (In my defense, they have a similar spelling. Oh, wait, who do I think I'm fooling with that?)
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: Use 2 files and print each line of each one side-by-side
by roboticus
in thread Use 2 files and print each line of each one side-by-side
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |