in reply to reading from an arbitrary number of files using anonymous file handles
Just for fun(?):
use strict; use warnings; my $wantedLines = shift; my %seen; while ( <> ) { print unless $seen{$_}++; last unless --$wantedLines; }
Update: Sorry, I posted the wrong version. Replace the contents of the while loop with:
unless ( $seen{$_}++ ) { print; last unless --$wantedLines; }
|
|---|