$s = <>; if($s =~ /(-?\d+)([\+-])(-?\d+)/){ if($2 eq '+'){ print $1-$3."\n"; }else{ print $1+$3."\n"; } }