This module does seem to leak. Other than that, it also uses
substr when it would be alot more efficient to use
pack/
unpack. It wouldn't be hard to set up a similar data structure of field names and lengths (and I've done it this way in the past), and convert that to one array of field names, and a format string that
unpack can use. Then just do a hash slice assignment like:
# Say we have an array of field names
# and a corresponding one of lengths
# (Decide for yourself if you want 'A' or 'a' here)
my $format_str = join '', map { "A$_" } @lengths;
while (<>) {
my %hash;
@hash{@names} = unpack($format_str, $_);
}
Update: The source of the 'leak' is that there is a package global array '@parse_record' which gets data
pushed to it for every field in every record. I think it was meant to save only one record, and should have been cleared on every new call to parse(). I've /msg'd a bug report to
princepawn :-)
Another update: I mentioned this further down the thread somewhere, but I thought I'd mention it further up here also, that I took princepawn's suggestion to take over the module, rewrote it, and it should be appearing soon at a CPAN near you :-)
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.