summaryrefslogtreecommitdiff
path: root/t/io
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-12-31 23:24:57 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-12-31 23:34:49 -0800
commit69974ce61d7459da5eda22eb31d730128757db37 (patch)
tree77493eb569a84e4a683da7951e720ba3c5ccb322 /t/io
parente38523840a8a9be645c93d91b9cd796de84f508c (diff)
downloadperl-69974ce61d7459da5eda22eb31d730128757db37.tar.gz
[perl #103492] Give lvalue cx to (s)printf args
Or potential lvalue context, like function calls. The %n format code’s existence renders these two very much like func- tion calls, as they can modify their arguments. This allows sprintf("...%n", substr ...) to work.
Diffstat (limited to 't/io')
-rw-r--r--t/io/print.t7
1 files changed, 6 insertions, 1 deletions
diff --git a/t/io/print.t b/t/io/print.t
index 321eb1e85b..00ee7fb591 100644
--- a/t/io/print.t
+++ b/t/io/print.t
@@ -10,7 +10,7 @@ BEGIN {
use strict 'vars';
-print "1..21\n";
+print "1..23\n";
my $foo = 'STDOUT';
print $foo "ok 1\n";
@@ -66,3 +66,8 @@ if (!exists &Errno::EBADF) {
map print(+()), ('')x68;
print "ok 21\n";
}
+
+# printf with %n
+my $n = "abc";
+printf "ok 22%n - not really a test; just printing\n", substr $n,1,1;
+print "not " x ($n ne "a5c") . "ok 23 - printf with %n (got $n)\n";