#this one works sub getNumbers{ foreach(@file){ next if m/(^#|^$)/; my ($cltnbr, $cltname) = split (' ', $_); print "$cltnbr"; } }