|
NAMEText::FixedLength::Extra - various niceties for Text::FixedLength lovers.SYNOPSISuse Text::FixedLength::Extra; #automatically uses Text::FixedLength my %format = (record_type => '3L', total_orders => '5R'); my @field_order = qw(record_type total_orders); my %data = (record_type => 'F', total_orders => 300); # Bonus One: Simplified API to Text::FixedLength ! $x = fixedlength(\%format, \%data, \@field_order); # Bonus Two: Zero filling and processing of integers and floating points ! my %format = (record_type => '3R', total_orders => '10R*F3'); my @field_order = qw(record_type total_orders); my %data = (record_type => 'F', total_orders => 300.52894); $x = fixedlength(\%format, \%data, \@field_order); DESCRIPTIONRight now, Text::FixedLength::Extra does two things for those who like using Text::FixedLength - simpler API and extended number processing.Simplified API to Text::FixedLengthA function, fixedlength() has been created which should make it easier to create fixed-width reports. Here is a sample of setting up data for use with fixedlength:# the fields we will format and their formatting instructions my %format = ( record_type => '3', upc => '13L', lcc_label => '5R', lcc_catalog => '7R', lcc_config => '1', artist_name => '30L', item_title => '30L', quoted_price => '6R', quantity => '4R', customer_title => '30L', customer_reference => '20L' ); # how to order the fields in %format my @format = qw(record_type upc lcc_label lcc_catalog lcc_config artist_name item_title quoted_price quantity customer_title customer_reference ); my %data = ( record_type => '23423' ... customer_reference => 'adfja;kdf'); my $formatted_line = fixedlength(\%format, %data, \@format); Number processingThe standard format instruction with Text::FixedLength isWIDTH JUSTIFICATION? E.g. 6L creates a left-justified field taking up 6 spaces, filling any non-used spaces with a spaces. This module re-implements the Text::FixedLength::getFixed function to handle additional optional syntax for formatting numbers. The new format instruction is: WIDTH JUSTIFICATION? (ZERO_FILL? D)? or WIDTH JUSTIFICATION? (ZERO_FILL? F PLACES_AFTER_DECIMAL)? If you dont understand the above let me give you a nice set of examples: 10R*F3 means uses 10 spaces, zero fill if necessary and allow 3 places after the decimal point. 10R*D means uses 10 spaces, zero fill if necessary. 10RF3 means uses 10 spaces, space fill (not zero-fill, note there was no * in the specification) if necessary and allow 3 places after the decimal point. EXPORTfixedlength()OVERWRITTENText::FixedLength::getFixed()AUTHORT. M. Brannon, <TBONE@CPAN.ORG>SEE ALSOperl(1). Parse::FixedLength
Visit the GSP FreeBSD Man Page Interface. |