Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Noone answered the question, and I'm also interested in knowing too. I don't know why they don't all behave one way or the other.

the "why" is explained in the docs, it's meant to produce a false value in a while loop.

from perldata#Slices

This makes it easy to write loops that terminate when a null list is returned: 1. while ( ($home, $user) = (getpwent)[7,0]) { 2. printf "%-8s %s\n", $user, $home; 3. }
If there's a reason to do it for list slices, the same reason exists for array slices.

The OP didn't use any array slices (jethro did). But I have to say I'm not happy with this non-orthogonality...

UPDATE: IMHO there should be a special perldoc only for lists explaining the differences to arrays and how to avoid confusion...

Cheers Rolf


In reply to Re^2: Array/List Strangeness by LanX
in thread Array/List Strangeness by Manchego

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 romping around the Monastery: (5)
As of 2024-04-16 22:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found