10 @a = (1,2,3,4,5,6,7,8,9,10,11,12);
12 while ($_ = shift(@a)) {
13 if ($x = /4/../8/) { $z = $x; push @b, $x + 0; }
16 is(join("*", @b), "1*2*3*4*5");
22 @a = ('a','b','c','d','e','f','g');
27 open(of,'harness') or die "Can't open harness: $!";
29 (3 .. 5) && ($foo .= $_);
31 $x = ($foo =~ y/\n/\n/);
39 # coredump reported in bug 20001018.008 (#4474)
52 $SIG{__WARN__} = sub { $warn .= join '', @_ };
56 like($warn, qr/uninitialized/);
61 ok((() = ($warn =~ /isn't numeric/g)) == 2);
67 push @_, \scalar(0..0) for 1,2;
68 isnt $_[0], $_[1], '\scalar($a..$b) gives a different scalar each time';
70 # This evil little example from ticket #122829 abused the fact that each
71 # recursion level maintained its own flip-flip state. The following com-
72 # ment describes how it *used* to work.
74 # This routine maintains multiple flip-flop states, each with its own
75 # numeric ID, starting from 1. Pass the ID as the argument.
77 my $depth = shift() - 1;
78 return f($depth) if $depth;
87 $accumulator .= "$outer $_\n" if f(2);
91 is $accumulator, <<EOT, 'recursion shares state';
105 # Void context gives parenthesized lhs scalar context
107 sub c { $context = qw[ void scalar list ][wantarray + defined wantarray] }
109 is $context, 'scalar', '(...)x... in void context';