The eval works fine, so long as you're not passing a constant -1 as an argument (which the compiler will catch and gripe about). Compare:
$ perl -le 'BEGIN { print "in begin" } eval { $i = <> ; $r = sqrt( -1 +) }; print ($@ ? "error: $@" : $r)' + in begin Can't take sqrt of -1 at -e line 1.
with
echo -1 | perl -le 'BEGIN { print "in begin" } eval { $i = <> ; $r = s +qrt( $i ) }; print ($@ ? "error: $@" : $r)' + in begin error: Can't take sqrt of -1 at -e line 1, <> line 1.
In reply to Re: negative sqrt()
by Fletch
in thread negative sqrt()
by Parham
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |