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

Re: Performance issue

by graff (Chancellor)
on Feb 18, 2009 at 14:49 UTC ( [id://744775]=note: print w/replies, xml ) Need Help??


in reply to Performance issue

Apart from the timing issue (where I think previous replies have been very helpful), I'd point out that your "Extract" sub really does not make sense as a subroutine. It receives and declares variables that are never used, and uses/alters variables that must be global in scope (because they're never declared) -- bad form in both cases.

You might want to get acquainted with Benchmark, and then maybe use that to compare alternate approaches. To use it effectively, you'll want to rethink your subroutine so that it's more "atomic" (independent, modular), which will be a Good Thing.

You might also consider split as an alternative to regex matching with captures. Based on the data shown, something like this would suffice:

$str = "mycompany----engineer=====itdept-----33"; my @pieces = split /\W+/, $str;
I don't recall off-hand what sort of timing difference this might yield (but Benchmark would be a good way to find out).

Maybe the stuff that your "Extract" sub is doing could be done without a sub call, and that might save some time (along with getting rid of the unnecessary print statements).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found