> I'm not sure what's ultimately going on here but quoting the argument
> to the eval somehow causes it to come up with a different answer than
> leaving it unquoted:
>
> $ perl -e "open qq/<nofile.dat/; print eval('$!{ENOENT}');"
> 0
> $ perl -e "open qq/<nofile.dat/; print eval($!{ENOENT});"
> 2
%! is a special variable. When Perl sees it at compile time, it loads
the Errno module and does tie %!, "Errno";. This load-and-tie process
might fail.
If $!{ENOENT} appears directly in the source code, then the
compilation of taint.t might fail because the load-Errno.pm-and-tie
process failed. In this case, taint.t emits no OK's.
The 'eval' is there so that if the load-and-tie fails, taint.t will
emit 72 OKs and one NOT OK.
eval '$!{ENOENT}'
tries to compute the value of $!{ENOENT}, and if that computation
fails, it catches the error. The computation involves loading
Errno.pm, tying %!, and doing FETCH('ENOENT').
eval $!{ENOENT}
evalutes $!{ENOENT} (FETCHing 'ENOENT', and possibly aborting the
program if that fails) and then takes the result of $!{ENOENT} and
passes it to 'eval' for a second evaluation. Since the result of
$!{ENOENT} is probably a number, the second evaluation has no effect.
However, your change does change the bhavior in cases where the module
load, the tie, or the FETCH fails. In the first two cases, these will
now cause a compile-time failure of the entire script where they
didn't before. In the FETCh case, these will cause a run-time failure
of the script that would not have occurred before,
I hope this clarifies the meaning of the comment in the taint.t file:
> --- t/op/taint.t;-0 Mon Mar 11 13:57:22 2002
> +++ t/op/taint.t Tue Mar 19 11:29:12 2002
> @@ -407,7 +407,7 @@
> # Try first new style but allow also old style.
> # We do not want the whole taint.t to fail
> # just because Errno possibly failing.
> - test 73, eval('$!{ENOENT}') ||
> + test 73, eval($!{ENOENT}) ||
Best,
-D.