#!/usr/bin/perl -w use strict; my $string = "4 I am thinking99 of a 34.56number" . "be110.2tween 100 an100d 1000, " . "and it isn't 55..."; # forgot the '+' qualifier on the split token! my @ary = split /[^\d.]+/, $string; for (@ary) { # don't need this anymore # next if /^$/ or !/\d/; # because of the way we split, # there could be multiple ".." s/[.]+/\./; # convert string to number (thanks to prev suggestion) $_ += 0; print $_, "\n"; }