while () { if (my $num = /start/ .. /end/) { print $num, "\t", $_; } } __DATA__ ignore start first second third end ignore start fourth fifth end ignore __OUTPUT__ 1 start 2 first 3 second 4 third 5E0 end 1 start 2 fourth 3 fifth 4E0 end