in reply to Merging files

while (my @lines = grep defined, (scalar <FILE1>, scalar <FILE2>)) { print RESULT @lines; }

Replies are listed 'Best First'.
RE: Re: Merging files
by merlyn (Sage) on Aug 27, 2000 at 16:05 UTC
    Brilliant!

    But dangerous as a pattern. Once you hit undef on ARGV (also known as the empty file handle or the diamond operator), you should stop reading from it, or you will end up reading from STDIN instead.

    So your post works fine for all filehandles that stay at EOF once you hit EOF. The magic ARGV filehandle does not.

    -- Randal L. Schwartz, Perl hacker