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

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.

Abigail


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (15)
As of 2014-08-22 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (160 votes), past polls