Help for this page

Select Code to Download


  1. or download this
    use strict;
    my @array = (1, 2, 3);
    my $item = 'z';
    foreach $item (@array) {}
    print($item);  # Prints 'z' (not '3'!!!).
    
  2. or download this
    use strict;
    my @array = (1, 2, 3);
    foreach my $item (@array) {}
    print($item);  # Compile error. $item only in scope for loop.