use warnings; use strict; use Scalar::Util qw(looks_like_number); while () { chomp; my $temp = $_; my $unit = lc chop $temp; if (looks_like_number($temp)) { print "temp = $temp : unit = $unit\n"; } } __DATA__ 55F 77c foo +0.4F