Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: chomp each element of array

by Laurent_R (Parson)
on Jun 10, 2013 at 12:38 UTC ( #1038056=note: print w/ replies, xml ) Need Help??


in reply to Re: chomp each element of array
in thread chomp each element of array

the array is evaluated in a list context.

Huh, it sounds a bit like a tautology, doesn't it? (Even though an array may be evaluated in a scalar context and return in this case the number of elements.)

I would rather say that the array is imposing a list context and that the chomp operator is used in a list context in this case. And, in such a case, it chomps all the elements of the list (and returns the total number of characters removed)

Note that if used on a hash, it chomps the hash's values, but not its keys.


Comment on Re^2: chomp each element of array
Re^3: chomp each element of array
by LanX (Canon) on Jun 10, 2013 at 16:23 UTC
    > I would rather say that the array is imposing a list context and that the chomp operator is used in a list context in this case.

    nope, you're wrong. the operator chomp imposes the context, thats how scalar @array works.

    I think @array can only impose list context as LHS of =, which becomes a list-assignment operator then.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2014-10-31 12:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (217 votes), past polls