Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -w
    
    ...
    foreach (@array) {
        printf "%s\n", $_;
    }
    
  2. or download this
    # Code sample 2 -- Come to think of it, I want the indices too ...
    
    ...
        my $item = $array[$i];
        printf "%3d.  $item\n", $i + 1;
    }
    
  3. or download this
    # Code sample 3 -- minor changes from the original "foreach"
    #                  loop (Code sample 1)
    ...
    foreach (@array) {
        printf "%3d.  %s\n", $loopcount + 1, $_;
    }
    
  4. or download this
        $#    The output format for printed numbers.  This variable
              is a half-hearted attempt to emulate awk's OFMT variable.
    ...
              number sign.)
    
              Use of $# is deprecated.