in reply to Re^2: what would you like to see in perl5.12?
in thread what would you like to see in perl5.12?
As I originally proposed it, I don't think it would. In any legal printf format, % is followed one of %*+- #csduoxefgXEGbpniDUOF\d..
Which I think means that %{...} would not conflict with any existing formats, and would generate: Invalid conversion in printf: "%{" if it appeared in any existing code. The lack of backwards compatibility issues is the nice thing about that original proposal. Albeit that I'd extend/mutate my original proposal to encompass some of the further discussion it generated.
It can easily be extended to make %{...} a generic, interpolate whatever is inside this embedded code block and convert the result to a string in the default manner.
And that could further be extended in a manner in keeping with normal printf rules so that it can become: %fw.p{...} where the f, w & p follow the same rules for flags, width & precision as are applied to the standard s specifier.
To simplify: %fw.p{xxx} acts pretty much like:
printf "%fw.ps", "@{[xxx]}"
The code xxx is evaluated, the result converted to as string, and the string substituted as if %s had been used.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: what would you like to see in perl5.12?
by JavaFan (Canon) on Aug 07, 2008 at 16:26 UTC | |
by BrowserUk (Patriarch) on Aug 07, 2008 at 17:48 UTC |