Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: How can we interpolate an expression??

by Anonymous Monk
on Sep 20, 2012 at 18:06 UTC ( #994714=note: print w/replies, xml ) Need Help??


in reply to Re: How can we interpolate an expression??
in thread How can we interpolate an expression??

http://perldoc.perl.org/perlintro.html#Scalars

print "The square of $answer is ", $answer * $answer, "\n";

print takes a list :) this list can be of a single item. join takes a list and makes it a single string

print join '', "The square of $answer is ", $answer * $answer, "\n";

you can also use the join operator (concatenation)

print "The square of $answer is ". $answer * $answer. "\n";

If you insist on interpolation, see

http://perldoc.perl.org/perltrap.html#Interpolation-Traps
@ always interpolates an array in double-quotish strings
Arbitrary expressions are evaluated inside braces within double quotes

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2016-12-04 23:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (70 votes). Check out past polls.