Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: parm#4 from caller == !"eval" ?

by choroba (Bishop)
on Sep 12, 2017 at 22:50 UTC ( #1199240=note: print w/replies, xml ) Need Help??

in reply to Re: parm#4 from caller == !"eval" ?

The documentation says:

$hasargs is true if a new instance of @_ was set up for the frame.

And that's how it works:

sub x1 { @_ = 'a'; &x2 } sub x2 { my ($c) = @_; say $c, (caller 0)[4] } x2('b'); # b1 x1(); # a

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^3: parm#4 from caller == !"eval" ?
by LanX (Bishop) on Sep 12, 2017 at 23:13 UTC
    Addendum to explain what the &x2 call does

    > Subroutines may be called recursively. If a subroutine is called using the & form, the argument list is optional, and if omitted, no @_ array is set up for the subroutine: the @_ array at the time of the call is visible to subroutine instead. This is an efficiency mechanism that new users may wish to avoid.

    Source perlsub

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      To you and choroba, thanks for the example(s). I completely forgot about the '&' case.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1199240]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2018-06-24 00:30 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.