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

Re: Why doesn't Perl provide %_ as the hash equivalent of @_ in subs?

by moritz (Cardinal)
on Sep 26, 2013 at 15:10 UTC ( #1055855=note: print w/replies, xml ) Need Help??

in reply to Why doesn't Perl provide %_ as the hash equivalent of @_ in subs?

There are at least four commonly used calling conventions for named arguments in existing Perl 5 code:

yoursub(a => 1); yoursub({ a => 1 }); $obj->meth(a => 1); $obj->meth({a => 1});

In addition, people like to mix positional arguments with named arguments, for example from AnyEvent::HTTP:

http_get $url, timeout => 20, sub { # callback here };

No, introducing %_ doesn't even begin to cover the use cases that are out in the wild, and it's another legacy feature that needs to be supported when/if proper routine signatures are introduced.

And that is the thing that should be done. There are several promising modules on CPAN that provide proper routine signatures, most of which converge on the syntax that Perl 6 uses. Getting one of them rock solid and into core Perl 5 would be a much better solution. (And I believe people are working on it already).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055855]
[panwarsagar]: I have started learning Perl and my moto is to process a text file and storing the contents in a Data Base
[erix]: perhaps try: Databases made easy

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (12)
As of 2017-03-28 12:29 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (330 votes). Check out past polls.