in reply to Changing the output filehandle while iterating input files.
It looks like you want something like this:
#!/usr/bin/perl use warnings; use strict; while ( <> ) { if ( $. == 1 ) { open OUTPUT '>', "out$ARGV" or die "Cannot open out$ARGV: $!"; } print OUTPUT; close ARGV if eof; }
|
|---|