Randy W. Sims wrote: > I just realized that this might be a little misleading. If you break it > down to: > > my $result = eval $header; > print $result; > > You will get an uninitialized value error. What happens is that > > eval $header > > is first interpolated to > > eval { # File: xyz } > > which is executed as perl code. As perl code this is a comment and so > produces no value, so $result ends up with no value, which is then > printed in the next line, generating the uninitialized value error.
i think you have the right idea but your example is a little "misleading", consider: [panda]# perl -W -le 'print eval "#"' [panda]# perl -W -le 'print eval {"#"}' # similiarly, now consider: [panda]# perl -W -le 'print eval undef' Use of uninitialized value in eval "string" at -e line 1. Use of uninitialized value in print at -e line 1. [panda]# perl -W -le 'print eval "undef"' Use of uninitialized value in print at -e line 1. [panda]# perl -W -le 'print eval {"undef"}' undef * we got 2 warnings for the first try because undef is evaluated once and then returned again to print * we got 1 warning because undef is returned from eval * we got no warnings for the last try because the string undef is returned from eval * eval{'#'} returns # not undef so your example above will not return undef * eval EXPR vs. eval BLOCK can be found at perldoc -f eval david -- s$s*$+/<tgmecJ"ntgR"tgjvqpC"vuwL$;$;=qq$ \x24\x5f\x3d\x72\x65\x76\x65\x72\x73\x65 \x24\x5f\x3b\x73\x2f\x2e\x2f\x63\x68\x72 \x28\x6f\x72\x64\x28\x24\x26\x29\x2d\x32 \x29\x2f\x67\x65\x3b\x70\x72\x69\x6e\x74 \x22\x24\x5f\x5c\x6e\x22\x3b\x3b$;eval$; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>