use warnings; use strict; open testFile, '>', 'delme.txt'; print testFile <) { my $current = $_; chomp $current; print "$.\n"; while () { print "$_" if $. == $current; } seek (testFile, 0, 0); $. = 0; } close testFile; __DATA__ 3 1 2