Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: how to get value of print command

by k_manimuthu (Monk)
on May 13, 2010 at 15:33 UTC ( #839851=note: print w/ replies, xml ) Need Help??


in reply to how to get value of print command

my $result = print "hello world\n";
For the above code $result get return value of "1". You want to get $result is "Hello world" you will be use the sprintf function.
my $var="Some Text"; my $result = sprintf "$var hello world "; print "$result\n";


Comment on Re: how to get value of print command
Select or Download Code
Re^2: how to get value of print command
by toolic (Chancellor) on May 13, 2010 at 15:57 UTC
    my $result = sprintf "$var hello world ";
    Don't do that. Not only is it a useless use of sprintf, but it is also an abuse of sprintf, whose 1st argument should be a format specification. This does the same thing:
    my $result = "$var hello world ";

      I tried it in different way to get the solution. Now i understand i should not use "sprintf", sorry for the inconvenience caused. I will give more attention for replying a thread in future.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-11-01 06:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (228 votes), past polls