Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: add a character at the end of a string

by jhourcle (Prior)
on Dec 13, 2005 at 12:18 UTC ( #516295=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub use_substr {
            my $string = shift;
            $string .= substr($string, -1) eq "/" ? "" : "/";
    ...
            'if_regex'  => sub { use_if_regex($_)  for @strings },
            'regex'     => sub { use_regex($_)     for @strings }
    } );
    
  2. or download this
    Benchmark: timing 100000 iterations of if_regex, if_substr, regex, sub
    +str...
      if_regex:  3 wallclock secs ( 2.50 usr +  0.00 sys =  2.50 CPU) @ 40
    +000.00/s (n=100000)
     if_substr:  2 wallclock secs ( 2.47 usr +  0.00 sys =  2.47 CPU) @ 40
    +485.83/s (n=100000)
    ...
    substr    38911/s       90%        --       -3%       -4%
    if_regex  40000/s       95%        3%        --       -1%
    if_substr 40486/s       98%        4%        1%        --
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2021-11-28 15:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?