while () { next unless /XXXX/; $. += 1; ### obviously this does not work ... print $_ ; }