Help for this page

Select Code to Download


  1. or download this
    for (1,2) {
        while (<STDIN>) {
        }
    }
    
  2. or download this
    for ("foo\n", "bar\n") {
      chomp;
      print;
    }
    
  3. or download this
    for my $str ("foo\n", "bar\n") {
      chomp $str;
      print $str;
    }
    
  4. or download this
    @bad = map {$_++} (1,2);
    @bad = grep {$_++} (1,2);
    
  5. or download this
    sub bad {
        $_[0]++;
    }
    bad(1);
    
  6. or download this
    my @good = (1,2);
    @good = sort {$a++ <=> $b} @good;
    
  7. or download this
    @bad = sort {$a++ <=> $b} (1,2);
    
  8. or download this
    my @bad;
    $bad[0] = [1];
    $bad[2] = [2];
    @bad = sort {$a->[0] <=> $b->[0]} @bad;