Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^7: perl eval

by Corion (Patriarch)
on Jul 05, 2010 at 19:01 UTC ( [id://848106]=note: print w/replies, xml ) Need Help??


in reply to Re^6: perl eval
in thread perl eval

#my $param = 'egal("7006","7006")'; #eval print $param; egal("7006","7006"); sub egal () { };

dies for me, with quite an instrutive message. What does it do for you?

Replies are listed 'Best First'.
Re^8: perl eval
by paribasu (Initiate) on Jul 05, 2010 at 19:13 UTC
    I am not getting any message.

      Oh - sorry - I should test my postings. You're not running with warnings, otherwise, you would have seen the following warning:

      > perl -w tmp.pl main::egal() called too early to check prototype at ..\tmp.pl line 3.

      What I meant to post was this:

      #my $param = 'egal("7006","7006")'; #eval print $param; sub egal () { }; egal("7006","7006");

      which outputs

      > perl -w tmp.pl Too many arguments for main::egal at ..\tmp.pl line 7, near ""7006")" Execution of ..\tmp.pl aborted due to compilation errors.

      Which is what also happens in your eval but which you never output because you never check for that. See previous posts on what to do.

        At last after a long fight I figured it out. It was due to defining the egal sub which is like:

        sub egal () { # .... }

        # Rather than:

        sub egal { # .... }

        This was imposing argument prototypes on egal (i.e. no args). This was the reason why Perl can't find the sub when an argument is passed.

Re^8: perl eval
by paribasu (Initiate) on Jul 05, 2010 at 19:19 UTC

    Have you run my second piece of code.. What is it's output??

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://848106]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-26 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found