Take me over?
NAME
Parse::FixedLength - parse a string containing fixed length fields into component parts
SYNOPSIS
use Parse::FixedLength;
my $parser = Parse::FixedLength->new([
first_name => 10,
last_name => 10,
address => 20,
]);
my $data = 'Bob Jones 1122 Main St. ';
my $parsed = $parser->parse($data);
or:
my $parser = Parse::FixedLength->new([qw(
first_name:10
last_name:10
address:20
)], {delim=>":"});
DESCRIPTION
The Parse::FixedLength
module facilitates the process of breaking a string into its fixed-length components.
PARSING ROUTINES
- new()
-
new($aref_format, $href_parameters)
This method takes an array reference of field names and lengths as either alternating elements, or delimited args in the same field.
An optional hash ref may also be supplied which may contain the following:
delim - The delimiter used to separate the name and length in the format array. spaces - If true, preserve trailing spaces in the parsed output. debug - Print field names and values during parsing (as a quick format validation check).
- parse()
-
parse($string_to_parse)
This function takes a string and returns the results of fixed length parsing as a hash reference of field names and values if called in scalar context, or just a list of the values if called in list context.
- pack($href_data_to_pack)
-
This function takes a hash reference and returns a fixed length format output string.
- names
-
Return an ordered arrayref of the field names.
EXAMPLES
see SYNOPSIS
AUTHOR
Douglas Wilson <dougw@cpan.org>,
original by Terrence Brannon <tbone@cpan.org>
COPYRIGHT
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.