View Single Post
Old 09-13-2007, 10:14 PM  
donborno
Confirmed User
 
Join Date: Jan 2007
Location: Vienna, Austria
Posts: 374
Code:
#!/usr/bin/perl -w
use strict;

my $INPUT = 'blabla.txt';
my $OUTPUT = 'blabla2.txt';
my $FOURTH_LINE = 'z';

open(my $fhi, $INPUT) or die "Cannot open $INPUT : $!";
open(my $fho, '>', $OUTPUT) or die "Cannot open $OUTPUT (writing): $!";

while (defined(my $line = <$fhi>)) {
    print $fho $line;
    print $fho $FOURTH_LINE, "\n" if ($. == 4);
}

close($fhi);
close($fho) or die "Cannot close $OUTPUT : $!";
But then again, it's 7 am.

Last edited by donborno; 09-13-2007 at 10:16 PM..
donborno is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote