Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
good chemistry is complicated,
and a little bit messy -LW

Comment on

I often find myself writing code like the following:
print "text text " . $obj->method1() . " more text " . $obj->method2() . " blah blah " . $obj->method3() . "\n";
A lot of concatenation, and it's not really easy to read. I could interpolate the method calls into the string using @{[]} tricks, but I find that to be ugly.
For some reason, I never remember the simple elegant solution, printf.
printf "text text %s more text %s blah blah %s\n", $obj->method1(),$obj->method2(),$obj->method3();
It's straight-forward, easy to read, and it lends itself much more easily to future localization, rewording, etc.

Probably obvious to most, but not all meditations need to be grand.


In reply to I don't use printf enough by dreadpiratepeter

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (2)
    As of 2014-03-17 05:52 GMT
    Find Nodes?
      Voting Booth?

      Have you used a cryptocurrency?

      Results (341 votes), past polls