in reply to Parse float from string

This works, but I don't know if it is what you are after:
#!/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"; }
It ain't pretty, but it does the trick.

UPDATE: fixed the split token to eliminate empty strings



PCS