foreach my $num (@array) { $num =~ s/\D//g; print $num; }