Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Passing array to a subroutine

by haukex (Abbot)
on Sep 13, 2017 at 13:51 UTC ( #1199305=note: print w/replies, xml ) Need Help??

in reply to Passing array to a subroutine

1nickt gave you a solution, just to explain what's going on: In Perl, arguments to subroutines/methods are by default flattened into one big list. So for example, if you have an array my @x = ('y', 'z'); and a function call like func(a=>@x, b=>'c');, and considering that the => is just a special kind of comma, what the function ends up getting called with is ('a', 'y', 'z', 'b', 'c'). This flattening is described in perlsub. To learn more about references, which are scalars and won't get flattened, see perlreftut.

A few minor updates for clarification.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2018-06-20 23:31 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.