On Mon, 18 Mar 2002, Jim Cromie wrote:
> Rich Morin wrote:
>
> > At 11:24 PM -0500 3/6/02, Uri Guttman wrote:
> >
> >> .... qn would be just like qq but not allow any
> >> direct hash interpolations (%foo or %foo{bar}). you can always get those
> >> with $() if needed. this solves the common case with a minimal of noise
> >> and the uncommon case has a simple out of using $(). no need for wacko
> >> ways to put in \n. it is double quotish in all ways but one and mainly
> >> to be used for printf format strings.
> >
> >
> > I also like this because it allows a typical format string to be
> > converted
> > merely by adding a two-character prefix:
> >
> > printf("The value is %7.2f\n", $foo);
> > ---
> > printf(qn"The value is %7.2f\n", $foo);
> >
> > -r
>
> if qf() is defensible, it should pass some generality tests;
>
> 1. make it 'replace' printf
> print qf'%s %d', $somestring, $someint;
>
> 2. make it 'replace' sprintf.
> $res = qf('%s %d %d', $somestr, $anint)
>
> 3. detect the silent error above - insufficient args.
> this quote-like operator is now a list-op, and a smart one.
>
> 4. make it know whether %s means hash interpolation or printf-format-spec
>
> a. ive seen perl5 warn about escaping @ when printing undefined / undeclared
> @array (cant seem to replicate now :-/ )
>
> b. the universe of printf format specs is pretty small, it really only
> interferes
> with (the expansion of: @{[ each %s ]} ) a few single letter hashes %s,
> %d, etc..
>
> c. item b implies a run-time check to see that no %s, %d, are hidden by
> a format-spec
> interpretation, but that is excessive; a comment in `perldoc -f printf`
> would address
> that rather fully.
I'm thinking, an operator really isn't needed is it? Hows about we extend
printf to support double quote-like escape sequences. So:
(s)printf 'Hello $foo,\n how %s you?', 'am';
Would print:
Hello $foo,
how am you?
In other words, we change printf, not the quotes.