http://www.perlmonks.org?node_id=643487


in reply to reading lines from 2 different files

Something like this:

# assuming you've got the files open in handles $fh1 and $fh2 while (1) { last unless defined($line_from_file_1 = <$fh1>); last unless defined($line_from_file_2 = <$fh2>); # ... }

Basically you just use the "read a record" operator (<>, aka diamond operator) on each file handle. See also readline.