use Regexp::Common qw(number); $_ = '#total mean for 530.2 nm = 411.67 W/m**2, dev= 0.2%'; if (/$RE{num}{real}{-keep}/) { print "$1\n"; }