in reply to Yet another does-function-exist question
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Yet another does-function-exist question (eval sub)
by kyle (Abbot) on Apr 14, 2007 at 16:33 UTC | |
by tye (Sage) on Apr 14, 2007 at 16:45 UTC | |
by naikonta (Curate) on Apr 14, 2007 at 16:59 UTC | |
|
Re^2: Yet another does-function-exist question (eval sub)
by xaprb (Scribe) on Apr 14, 2007 at 17:30 UTC |