$ans = <STDIN>; exit 0 if $ans =~ /^[Xx]/;
EXPR is omitted, the function exits with 0 status. You shouldn't
use exit to abort a subroutine if there's any chance that
someone might want to trap whatever error happened. Use die
instead, which can be trapped by an eval.