in reply to numbering lines problem

if ($_ != /^\d/) {print $y.$x;}    # if the line doesn't start with number then print numbers.

For future reference, also note that  !~ is "negated match", whereas  != is numeric not-equal, hence the warning. See perlop.