use strict; use warnings; my @num; while(my $string = ()){ $string =~ s/(\D+)//g; push @num, $string; } print $_ for(@num); __DATA__ Title: !! back!! 7073347120 FREE VaShiKaRaN SpeCiaLisT IN Allahabad Post: 707334712070733471207073347120707334712070733471207073347120