Data::File::Map - Read data file definitions stored as XML
use Data::File::Map; # load data file definition $map = Data::File::Map->new_from_file( 'path/to/map.xml' ); # read records from a data file using the map open FILE, 'data.txt' or die "Could not open file."; while( <FILE> ) { $record = $map->read( $_ ); } close FILE;
Data::File::Map will allow you to read in a data file definition stored as XML. The map can then be used to parse records in a data file. Handles delimited and formatted text data.
The format of the data file. Can be either csv for delimited files or 'text' for formatted ascii files.
csv
Used to separate variables in a csv file. This is a regular expression.
Attribute order is name, position, width, label;
Add a field to the map. If \%attributes is supplied, the position, width, and label attributes will be stored.
\%attributes
Returns a list of ArrayRefs containing information about the fields in the definition. The format off the ArrayRefs is [$field_name, $position, $width]. Position and width will only be defined in text files. If $want_objects will return a list of Data::File::Map::Field objects.
[$field_name, $position, $width]
text
$want_objects
Data::File::Map::Field
Returns a list of field names in the order defined in the definition file.
Returns the Data::File::Map::Field object with the given name.
Create a new Data::File::Map instance.
Create a new Data::File::Map instance and load definition from a file.
Create a new Data::File::Map instance and load definition from a string.
Load definition from a file.
Load definition from a string.
Takes a line from a data file and uses the definition to extaract the variables. Returns a HashRef with field names as keys.
Calls read on each line in the given file and returns an array of records.
read
Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>
Copyright (c) 2013 Jeffrey Ray Hallock.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Data::File::Map, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::File::Map
CPAN shell
perl -MCPAN -e shell install Data::File::Map
For more information on module installation, please visit the detailed CPAN module installation guide.