use strict; use warnings; my $cond=1; my $i=1 for $cond; for ($cond) { my $j=1; } #### my $cond = 1; foreach $_ ($cond) { my $i = 1; } foreach $_ ($cond) { my $j = 1; } #### #comments added on update #print "$i/n"; # Works for input code, not output code #print "$j/n"; # Fails for both