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

Re^3: Split does not behave like a subroutine

by LanX (Saint)
on Jul 22, 2020 at 19:44 UTC ( [id://11119675]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Split does not behave like a subroutine
in thread Split does not behave like a subroutine

Sorry, IMHO are you over-complicating.

Your definition of LIST is too narrow , it's not only used for function(LIST) and "comma" is not the only list constructor.

You can find LIST in docs for other cases too.

For me LIST means a piece of code which ...

  • is compiled in list context
  • returns a list value
nothing more.

for instance map {BLOCK} LIST ...

  • map { uc } qw/a b c/
  • map { uc } "a" .. "c"
  • map { uc } grep {...} ...
  • map { uc } "a", "b", "c"
  • map { uc } @a
only the last two list constructors allow "list interpolation/flattening", since it's a feature of the "comma operator" which has two variants , and '=>'.

correction: since it's a feature of the naked "list context" w/o operator, what comma does is just propagating the list context down the tree, hence @a=@b,@c is just @a = (@b),(@c)

FWIW: I use "interpolation" primarily for vars in strings like in print "$a $b";

But glossary lists both variants

  • interpolation

    The insertion of a scalar or list value somewhere in the middle of another value, such that it appears to have been there all along. In Perl, variable interpolation happens in double-quoted strings and patterns, and list interpolation occurs when constructing the list of values to pass to a list operator or other such construct that takes a LIST.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (8)
As of 2024-04-19 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found