G'day xnous,
Welcome to the Monastery.
Please follow the advice already given by ++hippo.
In addition to representative input data, show the expected output data.
Also, tell us what Perl version you're using: features in more recent Perls may improve performance.
Here's some very general advice:
-
Have a read of "perlperf: Perl Performance and Optimization Techniques".
Your basic steps should generally be:
get the code working; profile to find areas of poor performance;
benchmark to see if improvements are really improvements —
you'll probably need multiple iterations of some, or all, of these steps.
-
Reading all records into an array, then reading them all again from that array, is effectively doing the work twice.
Instead, read the records from the file and process them immediately.
Making a backup of the original file first, is advisable.
-
The performance of regexes can often be improved if they include anchors;
e.g. ^, $, \b, \b{}, and so on —
see "perlrebackslash: Perl Regular Expression Backslash Sequences and Escapes"
for details.
-
Use Regexp::Debugger to test individual regex patterns.
I use this module a lot and often find places where I can make improvements;
for instance, by eliminating backtracking.
When you provide the requested code and data, more specific advice will likely be possible.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.