Fortran::F90Format - Read and write data using FORTRAN 90 I/0 formatting
use Fortran::F90Format;
my $fmt = Fortran::F90Format->new(fmt=>"1x,a4,1x,i4,4(1x,i2)1x,f5.2");
my $input_string = ' STRG 1234 1 2 3 4 5 1000001.00';
my @input_values = $fmt->read( $input_string );
my @output_values = @input_values;
my $output_string = $fmt->write(@output_values);
print $output_string; # prints: " STRG 1234 1 2 3 4 5.00\n"
F90Format implements basic I/O formatting based on the Digital FORTRAN 90 I/O formatting specifications (April 1997). F90Format provides a consistent way of reading and writing fixed length fields in tabular data, by using the same syntax for reading and writing. The same task in Perl requires synchronizing the format strings in sprintf and pack/unpack functions. Although this is possible, sprintf sometimes exceeds the length of the desired field. This 'feature' of sprintf combined with the fact that pack/unpack never go beyond the desired field width may eventually result in corrupting the data table.
A format specification takes the following form:
Is a list of one of more Data Edit Descriptors, separated by commas. As an extension F90Format allows ommitting the external parenthesis.
DED transfer or convert data to or from the internal representation. DED take the following form:
[r]C
[r]Cw
[r]Cw.m
[r]Cw.d
[r]Cw.d[Ee]
r
repeat r times
C
Descriptor code, is one of the following ones: A,I,D,E,G,H,X
w
Total number of characters in the field
.
Dot to indicate that a decimal digits, or minimum digits field follows.
d
Number of digits to the right of the decimal point.
m
Minimum number of digits that must be in the field.
E
Identifies exponent field
e
Number of digits in the exponent.
Transfers characters or Hollerith values.
Transfers integer values.
Transfers real values with the letter D in the exponent.
Transfers real values with the letter E in the exponent.
Transfer real values with no exponent.
Transfer values of all intrinsic types.
Transfers n characters (ch) following the H Data Edit Descriptor
Skips n character positions to the right at the current position of the I/O.
Transfers the characters between the delimiters ' or ".
my $fmt = Fortran::F90Format->new( fmt => $format_string ); Creates a new object.
@output_values = $fmt->read( $input_string ); Reads from a string and returns the values extracted from it to an array.
my $output_string = $fmt->write( @values ); Writes formatted values from the input array into a string.
0.40
Fortran::Format
Victor Marcelo Santillan <vms@cpan.org>
Copyright (c) 2006 Victor Marcelo Santillan. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
3 POD Errors
The following errors were encountered while parsing the POD:
You can't have =items (as at line 461) unless the first thing after the =over is an =item
You forgot a '=back' before '=head2'
'=item' outside of any '=over'
To install Fortran::F90Format, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Fortran::F90Format
CPAN shell
perl -MCPAN -e shell install Fortran::F90Format
For more information on module installation, please visit the detailed CPAN module installation guide.