#!/usr/bin/perl use warnings; for ($x = 1; $x < 10; $x++) { if ($_ =~ /^\d/) {$y = $y + 1;} # if the line does start with a number, ignore it. if ($_ != /^\d/) {print $y.$x;} # if the line doesn't start with number then print numbers. }