Victor Marcelo Santillan > Fortran-F90Format-0.40 > Fortran::F90Format

Download:
Fortran-F90Format-0.40.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.40   Source  

NAME ^

Fortran::F90Format - Read and write data using FORTRAN 90 I/0 formatting

SYNOPSYS ^

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"

DESCRIPTION ^

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.

FORMAT SPECIFICATIONS ^

 A format specification takes the following form:
'(format-list)'
'format-list' (extension)

Format List

Is a list of one of more Data Edit Descriptors, separated by commas. As an extension F90Format allows ommitting the external parenthesis.

Data Edit Descriptors

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.

Summary of Data Edit Descriptors

A[w]

Transfers characters or Hollerith values.

Iw[.m]

Transfers integer values.

Dw.d

Transfers real values with the letter D in the exponent.

Ew.d[Ee]

Transfers real values with the letter E in the exponent.

Fw.d

Transfer real values with no exponent.

Gw.d[Ee]

Transfer values of all intrinsic types.

nHch[ch...]

Transfers n characters (ch) following the H Data Edit Descriptor

nX

Skips n character positions to the right at the current position of the I/O.

'ch[ch..]' or "ch[ch...]"

Transfers the characters between the delimiters ' or ".

METHODS ^

new
  my $fmt = Fortran::F90Format->new( fmt => $format_string );

  Creates a new object. 
read
  @output_values = $fmt->read( $input_string );

  Reads from a string and returns the values extracted from it to an
  array.
write
  my $output_string = $fmt->write( @values );
  
  Writes formatted values from the input array into a string.

VERSION ^

0.40

SEE ALSO ^

Fortran::Format

AUTHOR ^

Victor Marcelo Santillan <vms@cpan.org>

COPYRIGHT ^

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.

syntax highlighting: