- or download this
$_ = 42;
foreach (1, 2, 3) {
print "Inside loop: \$_ = [$_]\n";
}
print "Outside loop: \$_ = [$_]\n";
- or download this
$_ = 42;
while(<FH>) {
print "Inside loop: \$_ = [$_]";
}
print "Outside loop: \$_ = [$_]\n";
- or download this
foreach (@test_array) {
print qq|Before while: [$_]\n|;
...
print qq|After while: [$_]\n|;
}
- or download this
foreach my $elem (@test_array) {
open(IN, $0) || die "No file: $!\n";
while( defined(my $line = <IN>) ) { }
close IN;
}