Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: dot '.', comma ',' operators "oops" & "huh?"

by Abigail-II (Bishop)
on Aug 21, 2003 at 22:00 UTC ( [id://285600]=note: print w/replies, xml ) Need Help??


in reply to dot '.', comma ',' operators "oops" & "huh?"

According to perlop POD, "." an additive operator concatenates two strings, whereas comma operator "," in "scalar context it evaluates its left argument, throws that value away, then evaluates its right argument and returns that value."

Yeah, but what is your point? None of your examples use the comma operator in scalar context.

In practice, a lot of people use "." and "," interchangeably.

Actually, they don't, because in most cases, they lead to totally different things. About the only places where they are used more or less interchangeably are as arguments to functions, where the function concatenates all its arguments. print, warn and die are the most noteworthy. But here we talk about the comma as a list constructor, where the operator is in list context. Here the difference between the comma and the dot operators is that the comma operator gives list context to its operands, where the dot operator gives scalar context to its operands.

Abigail

  • Comment on Re: dot '.', comma ',' operators "oops" & "huh?"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-23 07:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found