Open p5pRT opened 5 years ago
For cases like
$ perl -we '@xyz = ( 1 .. 3 ); printf "X=%D Z=%d\n"\, @xyz[ 0\, 2 ];' X=1 Z=3
how about offering a different way: introducing the "absorber conversion"!
$ perl -we '@xyz = ( 1 .. 3 ); printf "X=%D%q Z=%d\n"\, @xyz;' X=1 Z=3
That's right\, "%q" has simply eaten its argument and done nothing!
Why would anybody want to do that? Well at least give users a choice.
(Just like the "unpack" function has an "x" template. See perlpacktut.)
On Wed\, 02 Oct 2019 19:57:25 GMT\, jidanni wrote:
This is a bug report for perl from jidanni@gmail.com\, generated with the help of perlbug 1.41 running under perl 5.28.1.
----------------------------------------------------------------- [Please describe your issue here]
For cases like
$ perl -we '@xyz = ( 1 .. 3 ); printf "X=%D Z=%d\n"\, @xyz[ 0\, 2 ];' X=1 Z=3
how about offering a different way: introducing the "absorber conversion"!
$ perl -we '@xyz = ( 1 .. 3 ); printf "X=%D%q Z=%d\n"\, @xyz;' X=1 Z=3
That's right\, "%q" has simply eaten its argument and done nothing!
Why would anybody want to do that? Well at least give users a choice.
(Just like the "unpack" function has an "x" template. See perlpacktut.)
Do you have any prior art for this feature request?
Internet search for "absorber conversion" mainly turns up links for automotive shock absorbers?
Thank you very much.
-- James E Keenan (jkeenan@cpan.org)
The RT System itself - Status changed from 'new' to 'open'
On Wed\, 02 Oct 2019 12:57:25 -0700\, jidanni wrote:
For cases like
$ perl -we '@xyz = ( 1 .. 3 ); printf "X=%D Z=%d\n"\, @xyz[ 0\, 2 ];' X=1 Z=3
how about offering a different way: introducing the "absorber conversion"!
$ perl -we '@xyz = ( 1 .. 3 ); printf "X=%D%q Z=%d\n"\, @xyz;' X=1 Z=3
That's right\, "%q" has simply eaten its argument and done nothing!
Why would anybody want to do that? Well at least give users a choice.
(Just like the "unpack" function has an "x" template. See perlpacktut.)
You can already use %.0s to do this:
$ perl -le 'printf "%s%.0s%s\n"\, "a"\, "b"\, "c"' ac
though this will try to convert that second parameter to a string\, which may have side-effects (like a warning if it's undef.)
$ perl -Wle 'printf "%s%.0s%s\n"\, "a"\, undef\, "c"' Use of uninitialized value in printf at -e line 1. ac
You can already reference printf parameters by index:
$ perl -le 'printf q(%1$s%3$s)\, "a"\, "b"\, "c\n"' ac
which avoids the side-effects:
perl -le 'printf q(%1$s%3$s)\, "a"\, undef\, "c\n"' ac
I don't know that there's much value to this change.
Tony
Migrated from rt.perl.org#134467 (status was 'open')
Searchable as RT134467$