Help for this page

Select Code to Download


  1. or download this
    # Modifies @array in-place.
    foreach (@array) {
       $_ = sprintf($format, $_);
    }
    
  2. or download this
    # Copies to a second array while formatting.
    my @formatted = map { sprintf($format, $_) } @array;
    
  3. or download this
    # Same as last, but without using "map".
    my @formatted;
    for (0..$#array) {
       $formatted[$_] = sprintf($format, $array[$_]);
    }
    
  4. or download this
    foreach (@formatted) {
       print($_, "\n");
    }