Help for this page

Select Code to Download


  1. or download this
    package RecordParser::FixedWidth;
    
    # constructor takes the name of the source file
    sub new {
        my ( $class, $source ) = @_;
    
  2. or download this
        my $template;
        my @fields;
        my @column_specs = lookup_specs($source);
    ...
            push @fields, $field;
        }
        open my $reader, '<', $source;
    
  3. or download this
        my $obj = {
            IO         => $reader,
            template   => $template,
    ...
        };
        bless $obj => $class;
    }
    
  4. or download this
    sub next {
        my ( $self ) = @_;
        my ($reader, $template, $fields_ref) 
    ...
    
        my $record = <$reader>;
        return unless defined $record;
    
  5. or download this
        my %value_of;
        my @values = unpack($template, $record);
        @value_of{@fields} = @values;
    
  6. or download this
        return \%value_of;
    }