|
Fortran::F90Format - Read and write data using FORTRAN 90 I/0 formatting |
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]
=item B<I>w[.m]
Transfers integer values.
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.
|
Fortran::F90Format - Read and write data using FORTRAN 90 I/0 formatting |