Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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


Comment on Re^2: How can we interpolate an expression??
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2014-07-31 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (252 votes), past polls