Parse::FixedRecord

Object oriented parser for fixed width records
Download

Parse::FixedRecord Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Jesse Luehrs
  • Publisher web site:
  • http://search.cpan.org/~doy/

Parse::FixedRecord Tags


Parse::FixedRecord Description

Parse::FixedRecord is a Perl subclass of Moose with a simple domain specific language (DSL) to define parsers.You may use any type constraints you like, as long as they have a coercion from Str. If you wish to output row objects in the same format, they should also have an overload.Parse::FixedRecord provides Duration and DateTime constraints for you out of the box.SYNOPSISAssuming you have data like this: Fred Bloggs | 2009-12-08 | 01:05 Mary Blige | 2009-12-08 | 00:30To create a parser: package My::Parser; use Parse::FixedRecord; # imports strict and warnings column first_name => width => 4, isa => 'Str'; pic ' '; column last_name => width => 6, isa => 'Str'; pic ' | '; column date => width => 10, isa => 'Date'; pic ' | '; column duration => width => 5, isa => 'Duration'; 1;In your code: use My::Parser; while (my $line = ) { eval { my $object = My::Parser->parse( $line ); say $object->first_name; do_something() if $ $object->duration->in_units('mins') > 60; }; }Product's homepage


Parse::FixedRecord Related Software