For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2005 > RE: Replacing printf by print









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: Replacing printf by print
Jeff 'japhy' Pinyan

2005-07-24, 8:29 pm

On Jul 22, pradeep.goel@wipro.com said:

> I am replacing it since there are some % sign in the strings being
> passed making the program crash. Replacement solves the problem as such,
> but wanted to countercheck, If these replacements could create any
> problem anywhere else! , or lator in the program?


The only problem there might be is that print() is susceptible to to the
$, and $\ variables. The $, variable defines what gets printed in between
the list of strings you pass to print(), and $\ defines what gets printed
after the strings you pass to print(). Both default to the empty string,
but if you were to change them, for some reason, print()s output would be
affected (but printf()s would not).

print "a", "b", "c"; # abc

$, = "!";
print "a", "b", "c"; # a!b!c

$\ = "?";
print "a", "b", "c"; # a!b!c?

But this is not likely to happen, methinks.

--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ % -- Meister Eckhart
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com