Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Want for a name?

by hdb (Monsignor)
on Dec 11, 2013 at 20:28 UTC ( [id://1066711]=note: print w/replies, xml ) Need Help??


in reply to Re: Want for a name?
in thread Want for a name?

Would there be a way to use $a and $b as in reduce?

Replies are listed 'Best First'.
Re^3: Want for a name?
by LanX (Saint) on Dec 11, 2013 at 20:40 UTC
    sure, you need to localize them.

    But $a and $b always have the risk to be lexicals from the outer scope², I wanted to avoid discussing that problem.¹

    It's about naming after all...

    Cheers Rolf

    ( addicted to the Perl Programming Language)

    ¹) compare this error

    DB<108> my $a=3; sort {$a <=> $b} @a Can't use "my $a" in sort comparison at ...

    ²) being bound to another package can be solved by investigating the caller, but checking for lexicals involves padwalker.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-25 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found