chomp($ask); # chomp() here rather than chop() if ($ask eq $add) { $z = $x + $y; print "$x + $y = $z";}