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

Re^3: CPAN Module to determing overlap of 2 lists?

by kcott (Archbishop)
on Aug 12, 2020 at 08:09 UTC ( [id://11120645]=note: print w/replies, xml ) Need Help??


in reply to Re^2: CPAN Module to determing overlap of 2 lists?
in thread CPAN Module to determing overlap of 2 lists?

I've generally found that Perl's functions that operate on strings (join, index, etc.) are typically very fast. You can compare with other solutions using Benchmark; you can profile to find hotspots (e.g. Devel::NYTProf).

I can see a number of micro-optimisations you could make: replace $ref_len - 1 with $#$ref and replace 1 + $#$ref with $ref_len. That may gain you absolutely nothing but, I suppose, the code would be a little neater.

You could do a single join. Then repeatedly chop the front off (index to locate JOIN then substr); again, that may gain you nothing but perhaps worth a try.

I, and no doubt others, would be interested in the results if you do decide to benchmark this against your current "brute force solution", a regex solution, and anything else you may have come up with.

— Ken

Replies are listed 'Best First'.
Re^4: CPAN Module to determing overlap of 2 lists?
by wazat (Monk) on Aug 13, 2020 at 01:03 UTC

    Your approach has some similarities to my brute force approach, but is more optimistic.

    Maybe I will do some benchmarking

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found