#1 slurping the whole thing in memory, and splice @file = <>; splice @file, 0, 4; print @file; #2 using the flip-flop operator while (<>){ next unless $.>3 .. 1; #... print; } #3 another flip-flop $start = -3; while (<>){ next unless $start++ .. 1; #.... print; } #4 just repeat 4 times $dummy=<> for 1..4; #5 make it multifile proof while (<>){ close( ARGV) if (eof);  next unless $.>3 .. eof; #... print; }