in reply to Obtaining header from file (first line) - printing to output file

Does changing

print OUTFILE head -1;

to

print OUTFILE $line if $. == 1;

do what you want?

If you're unfamiliar with $., it's documented in perlvar.

-- Ken

Replies are listed 'Best First'.
Re^2: Obtaining header from file (first line) - printing to output file
by gurpreetsingh13 (Scribe) on Jul 17, 2012 at 06:30 UTC
    or simply pumping in the entire file once(though not a good practice) and then filtering the first line.
    my @filelines=`cat $input_file`;print OUTFILE $filelines[0];