in reply to does anyone else use Parse::FixedLength;?

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 :-)

Replies are listed 'Best First'.
Re: Re: does anyone else codeuse Parse::FixedLength;/code?
by cmilfo (Hermit) on Jun 21, 2001 at 23:26 UTC
    Thank you!