Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: framework for data parsing

by Narveson (Chaplain)
on Jun 20, 2008 at 21:34 UTC ( #693226=note: print w/replies, xml ) Need Help??

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;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://693226]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2022-11-30 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?