How to expand hash into argument list in function call in Perl? I am searching Perl equivalent of Python’s syntax : somefunc(**somedict) or somefunc(*somelist). Is that possible in Perl?
How to expand hash into argument list in function call in Perl? I am
Share
In Perl, all function arguments are passed as lists and stored in the special array variable
@_. You can copy those values to some other array, or directly into a hash (as you can with any array/list).If you are writing a function, you can pass the arguments directly into an array or hash:
To call a function like that, just pass them as if they were a list or hash:
If you already have the arguments in a variable, just pass them along and Perl flattens out the array/hash into the argument list: