Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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

by Abigail-II (Bishop)
on Aug 21, 2003 at 22:00 UTC ( #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.


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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://285600]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2018-05-23 17:11 GMT
Find Nodes?
    Voting Booth?