sub definedWord { my( $word )= @_; return eval "use strict; my \$x= sub { $word }; 1" || ( warn("$@\n"), $@ !~ /^Bareword/ ); } @ARGV= qw( definedWord time system foo BEGIN if -e lt goto last ) if ! @ARGV; for( @ARGV ) { printf "$_:\t%sdefined\n", definedWord($_) ? "" : "UN"; }
is one interesting interpretation, producing:
definedWord: defined time: defined system: defined Bareword "foo" not allowed while "strict subs" in use at (eval 4) line + 1. foo: UNdefined BEGIN: defined syntax error at (eval 6) line 1, at EOF if: defined -e: defined syntax error at (eval 8) line 1, near "{ lt" lt: defined goto: defined last: defined
- tye
In reply to Re: Yet another does-function-exist question (eval sub)
by tye
in thread Yet another does-function-exist question
by xaprb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |