Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: framework for data parsing

by Narveson (Chaplain)
on Jun 20, 2008 at 21:34 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-16 16:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found