Re: regex to clean path

From: Uri Guttman (uguttman_at_athenahealth.com)
Date: 10/21/04


Date: Thu, 21 Oct 2004 16:08:11 -0400


>>>>> "p" == parv <parv_@yahooWhereElse.com> writes:

>> the overall impression is that you have the tendency to abuse
>> printf() and referencing-dereferencing

  p> I do not agree about printf() at all, but do agree in some limited
  p> ways about references.

printf is so rarely needed in perl. you can usually use interpolation,
sprintf, or formats (which i have never used in 11 years of perl
hacking). and i would prefer sprintf as then you can easily control
where the output goes rather than always going to a single handle. think
about the cases where you want output to be returned instead of printed,
or sent to two places like stdout and a log, etc. my rule for this is:

        print rarely, print late.

print rarely means don't call print so often as it is slow. use .= to
build strings as that is fast.

print late means don't print until you have all the text you want in one
string. that way you can easily decide to print to multiple places and
control the printing. my dump, status and other text generating routines
always build strings and return them. their caller can decide to print
or add other text to them and return to a higher caller, etc. if you
print in a low level sub, you can't prepend text or mung it or control
its output.

so printf falls under that rule but since sprintf does the same work but
returns the string, i never use printf.

uri



Relevant Pages

  • Re: Beginner Reg.Expression Question
    ... printf "%vd\n", $v; ... $ perl -wle ' ... Version Strings (v-strings) have been deprecated. ...
    (perl.beginners)
  • Re: printf resisting to be used
    ... This is the same type that main has in a haskell program. ... you can eliminate the coercion ... to Float in the printf argument by making the type of interest ... represent the action of printing the strings, ...
    (comp.lang.functional)
  • Re: A Use of Static Typing
    ... which dynamic typing or type inference would allow. ... myprintf s = format s ... instance Printf ) where ... *obviously* does not accept strings, no matter what type system you are ...
    (comp.lang.misc)
  • Re: convert int to char
    ... >>>Does anyone have a function or procedure for converting integers to ... printf() is indeed capable of converting integers to character ... strings -- it just has its own ideas about where the character ...
    (comp.lang.c)
  • Re: convert int to char
    ... > printf() is indeed capable of converting integers to character ... > strings should end up. ... > one closed stdout, nmap'd some memory, took the fd from that [which ...
    (comp.lang.c)

Loading