Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Stuck in komplexer regex, at least for me

by Moron (Curate)
on Mar 26, 2007 at 15:55 UTC ( #606602=note: print w/ replies, xml ) Need Help??


in reply to Stuck in komplexer regex, at least for me

I think you are suffering slightly from the popular compulsion to do everything in the regexp. Personally, I would have gone for the simplest thing that came to mind e.g.:

my $keep = substr( $_, 0, 2 ); $_ = substr( $_, 2, length($_) ); s/0+/0; $_ = $keep . $_;
and then also reassured myself that such a simple regexp should gain significantly in performance and should win the trade-off against having the extra substr operations which are cheap by comparison to m//.

-M

Free your mind


Comment on Re: Stuck in komplexer regex, at least for me
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2015-07-05 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls