Help for this page

Select Code to Download


  1. or download this
        my @array = (1,2,3);
        $_ *= 2 for @array;
        print "@array\n";     # prints: 2 4 6
    
  2. or download this
        $_ *= 2 for 1,2,3;  # error: modification of read-only value
    
  3. or download this
        my @array = (1,2,3);
        for my $e (map $_, @array) {
            $e++; # or whatever
        }
        print "@array\n";