while (<>) { # edit line if needed. print $_; } #### my $line = 0; while (<>) { ++$line; next if ($line < 3); # skip first two lines s/XXXX/YYYY if ($line == 3); # change third line print $_; }