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

Re: Doubley surprised by fat commas (updated)

by AnomalousMonk (Archbishop)
on Jun 09, 2021 at 22:05 UTC ( [id://11133708]=note: print w/replies, xml ) Need Help??


in reply to Doubley surprised by fat commas

Similar to parv's comment: A function argument list is a list (and assigned to the magical @_ array), and Perl flattens lists.

Win8 Strawberry 5.8.9.5 (32) Wed 06/09/2021 17:59:05 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings use Data::Dump qw(dd); sub fun { dd \@_; } fun('foo'); fun('foo',,,,,,,,); # fun(,,,,,,,,'foo'); # syntax error! # fun(,'foo'); # syntax error! fun('foo','bar'); fun('foo',,,,,,,'bar'); fun('foo' => => => => => => 'bar'); ^Z ["foo"] ["foo"] ["foo", "bar"] ["foo", "bar"] ["foo", "bar"]
(Update: Same results under Strawberry 5.30.3.1 (64).)

Update: Note that fun( => 'foo') is also a syntax error.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-03-28 19:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found