Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: I was expecting 4 elements in the array, but it only has 3

by j41r (Beadle)
on Nov 30, 2018 at 00:18 UTC ( [id://1226520]=note: print w/replies, xml ) Need Help??


in reply to I was expecting 4 elements in the array, but it only has 3

According to List value constructors:

when a LIST is evaluated, each element of the list is evaluated in list context, and the resulting list value is interpolated into LIST just as if each individual element were a member of LIST.

It also says:

The null list is represented by (). Interpolating it in a list has no effect. Thus ((),(),()) is equivalent to ()

Paladin and haukex have already explained why m// is returning an empty list, but you can also check it by yourself in Regexp Quote Like Operators:

If the /g option is not used, m// in list context returns a list consisting of the subexpressions matched by the parentheses in the pattern, that is, ($1, $2, $3...) (Note that here $1 etc. are also set). When there are no parentheses in the pattern, the return value is the list (1) for success. With or without parentheses, an empty list is returned upon failure.

Replies are listed 'Best First'.
Re^2: I was expecting 4 elements in the array, but it only has 3
by AnomalousMonk (Archbishop) on Nov 30, 2018 at 03:43 UTC
    On the other hand ...

    But nothing in the second quote from the docs is "on the other hand" or, as I would interpret the phrase, "contrary" to the first quote. Did you mean to suggest otherwise?


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

      Oh, thank you AnomalousMonk for your suggestion. You’re right. Do you think the phrase "in addition" would be appropriate here, instead of "on the other hand"?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2024-04-19 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found