Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
The stupid question is the question not asked
 
PerlMonks  

Commas and Periods

by TGI (Parson)
on May 07, 2001 at 22:26 UTC ( [id://78687]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Re: CGI.pm, combining two strings
in thread CGI.pm, combining two strings

The comma operator (,) acts as a list separator. When you feed print and bunch of stuff with commas in-between you are saying print this list of things. In a scalar context the comma evaluates the left arg and dumps the value, then it evaluates the right arg and returns the result.print scalar('foo','bar','this'); gets you this

The period (.) is the string concatenation operator. It combines strings. It also wants its operands in scalar context.

$a = 'abc'; $d = 'def'; $A = $a.$b; #ie, $A='abcdef' print $A.$a.$b;

This code prints abcdefabcdef. Here I say print this one thing that you can make by putting these things together.

Though they seem to do much the same thing when you're printing, they are actually quite different. Watch out for the scalars only aspect of .!


TGI says moo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://78687]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.