Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: difference between ($scalar) and $scalar

by elbie (Curate)
on Jul 21, 2001 at 15:48 UTC ( [id://98655]=note: print w/replies, xml ) Need Help??


in reply to difference between ($scalar) and $scalar

It is a difference between the list and scalar contexts. Your pattern matching operation will return a list, but if the assignment is to a scalar (as it is in the second case) then you only get the scalar value of the list. i.e. The number of elements in the list. In this case, that's the number of matches made.

If the assignment is made to a list, which you can explicity do by putting the brackets around the variable as in your first case, then you will get the elements of the left hand side's list (in this case, the one variable $rcs) matched up with the elements of the right hand side (the matches from the regexp) on a one-for-one basis until one side reaches the end of the list.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-29 01:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found