From aabe9514ecdf64c885843e2a9440477e5a96d4c8 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Wed, 4 Feb 2004 19:50:05 +0000 Subject: The "my $_" wasn't nice with foreach loops. p4raw-id: //depot/perl@22268 --- t/op/mydef.t | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/op/mydef.t b/t/op/mydef.t index 700a3dc5f7..0770e78f0b 100644 --- a/t/op/mydef.t +++ b/t/op/mydef.t @@ -5,7 +5,7 @@ BEGIN { @INC = '../lib'; } -print "1..56\n"; +print "1..64\n"; my $test = 0; sub ok ($$) { @@ -65,6 +65,23 @@ $_ = "global"; ok( $_ eq 'local', '...my $_ restored outside for my $_' ); ok( our $_ eq 'global', '...our $_ restored outside for my $_' ); } +{ + my $_ = 'local'; + for ("implicit foo") { # implicit "my $_" + ok( $_ eq "implicit foo", 'for implicit my $_' ); + /(.)/; + ok( $1 eq "i", '...m// in for implicity my $_' ); + ok( our $_ eq 'global', '...our $_ inside for implicit my $_' ); + } + ok( $_ eq 'local', '...my $_ restored outside for implicit my $_' ); + ok( our $_ eq 'global', '...our $_ restored outside for implicit my $_' ); +} +{ + my $_ = 'local'; + ok( $_ eq "postfix foo", 'postfix for' ) for 'postfix foo'; + ok( $_ eq 'local', '...my $_ restored outside postfix for' ); + ok( our $_ eq 'global', '...our $_ restored outside postfix for' ); +} { for our $_ ("bar") { ok( $_ eq "bar", 'for our $_' ); -- cgit v1.2.1