in reply to How to use sprintf %n formatting pattern
https://perl5.git.perl.org/perl5.git/blob/HEAD:/t/op/sprintf2.t#l1174 Instructions 173 # In each of the following lines, there are three required fields:... https://perl5.git.perl.org/perl5.git/blob/HEAD:/t/op/sprintf.t#l173 https://perl5.git.perl.org/perl5.git/blob/HEAD:/t/op/sprintf.t#l4811170 1171 { 1172 # gh #17221 1173 my ($off1, $off2); 1174 my $x = eval { sprintf "%n0%n\x{100}", $off1, $off2 }; 1175 is($@, "", "no exception"); 1176 is($x, "0\x{100}", "reasonable result"); 1177 is($off1, 0, "offset at start"); 1178 is($off2, 1, "offset after 0"); 1179 } 1180
I imagine running the test file might show whats executed481 >%s< >sprintf('%%n%n %d', $n, $n)< >%n 2< >Slight sneakiness to te +st %n< 482 >%s< >$n="abc"; sprintf(' %n%s', substr($n,1,1), $n)< > a1c< >%n +w/magic< 483 >%s< >no warnings; sprintf('%s%n', chr(256)x5, $n),$n< >5< >Unico +de %n< 484 >
|
|---|