Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How can we interpolate an expression??

by Marshall (Prior)
on Sep 21, 2012 at 07:43 UTC ( #994836=note: print w/ replies, xml ) Need Help??


in reply to How can we interpolate an expression??

my $number = 5; my $multiplier = 3; # Use print instead of "say" print "Product is ", $number * $multiplier, "\n"; __END__ Product is 15
"say" is a short hand way to add the "\n" at the end of the line.
when you don't mean or need that, just old fashioned print will work great.


Comment on Re: How can we interpolate an expression??
Download Code
Re^2: How can we interpolate an expression??
by Rohit Jain (Sexton) on Sep 21, 2012 at 07:52 UTC

    Well, the only one different that I know between print and say is that: -

    -->"say" adds a Newline to the output, whereas we have to give it explicitly in "print".

    Is there any other different??

      my $number = 5; my $multiplier = 3; # Use print instead of "say" print "Product is ", $number * $multiplier, "\n"; #this does not work... #"say" has limitations... say "Product is ", $number * $multiplier; __END__ Product is 15
      "Say" will add a \n to a simple string. More complex things require "print" or "printf".

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2014-10-01 00:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (386 votes), past polls