Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Sorry that's too complicated for me, TL;DR

> I have to understand what (LIST) means in the documentation.

According to the docs cited in

List's terminology and Parentheses in Perl

<updated>

Uppercase "LIST" in perldocs is a argument placeholder for any code ...

  • compiled in "list context"
  • delivering a "list value" at run time

For instance from the docs for print ...

print LIST; means that ...

  • print 1,2,3;

    the two commas are compiled to create a "list value" 1,2,3 for print

  • print @a;

    the array @a will be compiled to pass it's content as "list value" ( i.e.not his length from scalar context)

  • print func();

    the sub &func will be called in "list context" at run time and return a "list value" from it's last statement. ( compare wantarray )

</updated>

> To understand this:

> > The scalar comma operator returns the last element.

> I must understand in which list it is the last element.

Comma separated lists (sic)

Please compare (updated)

# --- list assignments @a = (1,2,3); # list comma @a = (1..3); # list range ($a) = @a; # deconstruction => $a==1 # --- scalar assignments $a = (1,2,3); # scalar comma $a = (1..3); # flip flop operator ... Oo oops! $a = @a; # scalar @a == length

The parens on RHS only do grouping here they do not create a list. Hence the context is propagated to the operators , and ..

@a = and (...)= are "list assignment" imposing "list context".

The range 1..3 returns the list value 1,2,3 in list context only.

You have to think of the whole statement as an op-tree...

  • propagating context down
  • passing "values" up

With ...

  • operators changed by upper context
  • operators (sometimes) creating down context

If that's not clear enough please show a short code exemplifying your problem.

HTH

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

update

you may want to play around yourself with B::Deparse and B::Concise to experiment around with the snippets shown

perl -MO=Deparse,-p -e "CODE"

and

perl -MO=Concise -e "CODE"


In reply to Examples for "LIST", "list context", "list value", "list assigment", "list operator" by LanX
in thread Split does not behave like a subroutine by bojinlund

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-24 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found