Where is the difference between the following two Statements?
print "surname=" ,$myVal, "\n";
and
print "surname=" .$myVal. "\n"
I’ve tested them and both return the same result. Is there even a difference?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A Perl programmer would probably write that as:
It does look like it’s doing the same thing, doesn’t it? And in your example it does do the same thing. The difference is more obvious if you replace the scalar variable with an array.
The difference is in the number of arguments that are passed to the print function. If you use the concatenation operator (.) then your arguments are concatenated together into one string and print gets a single argument. If you use the comma, then print gets a list of arguments.
Of course, it’s possible to mix the methods in the same print call.
Another nice example is to use the return value from localtime.