Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Question about regex performance

by ted.byers (Monk)
on Jun 17, 2014 at 22:06 UTC ( [id://1090217]=perlquestion: print w/replies, xml ) Need Help??

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>
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1090217]
Approved by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 03:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found