SPUG: double quotes vs printf

Michael R. Wolf MichaelRWolf at att.net
Thu Jun 21 21:34:08 PDT 2007

When I've got to print a long string with variable interpolation, I often

print " Lorem ipsum dolor sit $var1, consectetuer adipiscing $var2. In


  printf 'Lorem ipsum dolor sit %s, consectetuer adipiscing %s. In felis',
          $var1, $var2;

or even

  my $fmt = 'Lorem ipsum dolor sit %s, consectetuer adipiscing %s. In felis'
  printf $fmt, $var1, $var2;

I think it separates the presentation from the content.  I can save the
older/stupider (i.e. me, later) reader from having to parse and interpolate
the format string by factoring it out of the print, and signaling the same
by surrounding it with single (non-interpolating) quotes.

I haven't seen wide spread use of this refactoring.  Have you?

What's your opinion of this practice?

Although I've seen folks replace comma with fat-comma, I don't like it.
Guess fat-comma feels too much like a duple to me.

  printf $fmt => $var1, $var2;

Michael R. Wolf
    All mammals learn by playing!
        MichaelRWolf at att.net

More information about the spug-list mailing list