Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI )

by LanX (Saint)
on Dec 13, 2013 at 22:53 UTC ( [id://1067081]=note: print w/replies, xml ) Need Help??


in reply to Re: Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI )
in thread Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI ;)

The arrow does not work on lists nor arrays (it imposes scalar context +, so it operates on the last member or size, respectively):

Deeper meditation ...=)

Non-scalars are usually simple variables, so the normal function-call syntax can be comfortably applied, for the nested cases you can use the method syntax:

DB<134> sub multi (\@) { print "@{$_[0]}" } DB<135> $multi=\&multi => sub { "???" } DB<136> @array=1..5 => (1, 2, 3, 4, 5) DB<137> multi @array 1 2 3 4 5 DB<141> (\@array)->$multi() 1 2 3 4 5 DB<138> $h[0][1][2]=\@array => [1, 2, 3, 4, 5] DB<139> $h[0][1][2]->$multi() 1 2 3 4 5

I can think of cases were this flexibility of interface comes handy.

Cheers Rolf

( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found