in reply to Re^2: eval sub
in thread eval sub
I don't believe prototyping to be an issue here.
Maybe. What I meant is probably best expressed with a simple snippet of code, which resembles in essence what I understood you're trying to do (but without the XML and stuff):
my $code = << 'EOC'; sub mySub() { print "args: @_\n"; } EOC eval $code; print qq(\ncalling 'mySub()'\n); eval 'mySub()'; print "error: $@" if $@; print qq(\ncalling 'mySub("hello world")'\n); eval 'mySub("hello world")'; print "error: $@" if $@;
Running this gives:
calling 'mySub()' args: calling 'mySub("hello world")' error: Too many arguments for main::mySub at (eval 3) line 2, near ""h +ello world")
As you can see, the second call (with arguments) fails with the prototype in place. And it fails silently, unless you check $@.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: eval sub
by samip (Novice) on Oct 10, 2008 at 13:49 UTC | |
by almut (Canon) on Oct 10, 2008 at 14:41 UTC |