Help for this page

Select Code to Download


  1. or download this
           If any part of LIST is an array, "foreach" will get very confus
    +ed if
           you add or remove elements within the loop body, for example wi
    +th
           "splice".   So don’t do that.
    
  2. or download this
      @foo = map { 'd' eq $_ ? ($_,'h') : $_ } @foo;
      # puts 'h' right after 'd'
    
  3. or download this
    my @extras;
    foreach my $x (@foo) {
    ...
    # didn't print 'h'.  But if we add:
    print foreach @extras;
    # that works ... but duplicates code.
    
  4. or download this
    {
      my @extras;
    ...
    {
      print $x;
    }