>I like the idea, but wonder how to avoid problems that could arise with
>things like,
>
>$raise = "15%";
>printx(
>       'My raise was %s this year!', $raise
>);

In this particular case, there would be no problem, because $raise
would be "consumed" by the "%s" in the initial string and would not
be evaluated for format descriptions.  There is a problem, however;
if a variable contains a percent sign and is not consumed by a
preceding format description, it could confuse printx.  Hmmmm.

I like being able to simply include variables and strings, letting
them auto-convert (as in print).  OTOH, my proposal has some holes
(as you note) and may not be easy to error-check.

The C# syntax looks interesting.  I suspect that some variant of it
could be dropped into Perl as a module, so it wouldn't break anything.

Here's another approach, FWIW:

    print
      f('The value of $foo is %f7.3; ',  $foo),
      f('the value of $bar is %f7.3.%n', $bar);

    print
      f('The values of $foo and $bar are %f7.3 and %f7.3, ', $foo, $bar),
      'but the value of $baz ', f('is %f7.3%n', $baz);

This assumes that the first argument to "f" is a format description
and the other values are its arguments.  Careful reader will note that
"f" is basically sprintf.

-r
-- 
email: [EMAIL PROTECTED]; phone: +1 650-873-7841
http://www.cfcl.com/rdm    - my home page, resume, etc.
http://www.cfcl.com/Meta   - The FreeBSD Browser, Meta Project, etc.
http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series
http://www.ptf.com/tdc     - Prime Time Freeware's Darwin Collection

Reply via email to