Parse::Binary::FixedFormat::Variants

Parse::Binary::FixedFormat::Variants is a Perl module to convert between variant records and hashes.
Download

Parse::Binary::FixedFormat::Variants Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Autrijus Tang
  • Publisher web site:
  • http://search.cpan.org/~autrijus/

Parse::Binary::FixedFormat::Variants Tags


Parse::Binary::FixedFormat::Variants Description

Parse::Binary::FixedFormat::Variants is a Perl module to convert between variant records and hashes. Parse::Binary::FixedFormat::Variants is a Perl module to convert between variant records and hashes.Parse::Binary::FixedFormat supports variant record formats. To describe a variant structure, pass a hash reference containing the following elements to new. The object returned to handle variant records will be a Parse::Binary::FixedFormat::Variants.ChooserWhen converting a buffer to a hash, this subroutine is invoked after applying the first format to the buffer. The generated hash reference is passed to this routine. Any field names specified in the first format are available to be used in making a decision on which format to use to decipher the buffer. This routine should return the index of the proper format specification.When converting a hash to a buffer, this subroutine is invoked first to choose a packing format. Since the same function is used for both conversions, this function should restrict itself to field names that exist in format 0 and those fields should exist in the same place in all formats.FormatsThis is a reference to a list of formats. Each format contains a list of field specifications.For example: my $cvt = new Parse::Binary::FixedFormat { Chooser => sub { my $rec=shift; $rec->{RecordType} eq '0' ? 1 : 2 }, Formats => , , ] }; my $rec0 = $cvt->unformat("0FieldABBBB"); my $rec1 = $cvt->unformat("1FldC");In the above example, the Chooser function looks at the contents of the RecordType field. If it contains a '0', format 1 is used. Otherwise, format 2 is used.Parse::Binary::FixedFormat::Variants can be used is if it were a Parse::Binary::FixedFormat. The format and unformat methods will determine which variant to use automatically. The blank method requires an argument that specifies the variant number. Requirements: · Perl


Parse::Binary::FixedFormat::Variants Related Software