my ($LowValue, $HighValue) = split("-", $form{'searchprice'}); #makes the two values to compare $Price with if ($desc =~ m/\$(\d{1,3},?[\d{3},?]*\.?\d{0,2})/) { my ($Price) = $1; #sets $Price equal to the match in the regex $Price =~ s/,//g; #Strips out all commas if (($LowValue <= $Price) && ($Price <= $HighValue)) { print "$desc\n"; } } else { print "No price found in $desc\n"; }