Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -d:NYTProf
    
    ...
      $string = join ' ', split ' ', $string;
      return $string;
    }
    
  2. or download this
    #!/usr/bin/perl -d:NYTProf
    
    use warnings;
    ...
        $string =~ s/(?:^ +)||(?: +$)//g;
        return $string;
    }
    
  3. or download this
    ted@linux-jp04:~/Work/Projects/misc.tests> ./compress.multiple.spaces.
    +to.single.space.pl
                   Rate compress_3 compress_1 compress_2 split_join     sq
    +uash
    compress_3 135174/s         --        -2%        -6%       -34%       
    +-45%
    ...
    'regex_or' => 'Mary had a little lamb.'                               
    +                                                                     
    +                                       
    'one_liner' => 'Mary had a little lamb.'                              
    +                                                                     
    +                                       
    ted@linux-jp04:~/Work/Projects/misc.tests>