in reply to New to PERL - file format conversions to do

Side note: Please do not double post. You can edit your posts or add additional notes instead.

This is a simple example to get you started:

$/ = \ 7 * 1024; # read 7 K records. while (<>) { # read record into $_ my $info = substr($_, 0, 1000); # put first 1000 bytes in $info my $lab = substr($_, 1000, 1000); my $diagnosis = substr($_, 20000, 49999); my $last = chop; # get last character # now do stuff with that data }

Replies are listed 'Best First'.
Re^2: (dup) Perl for flat file conversions?
by runrig (Abbot) on Jun 07, 2006 at 22:33 UTC
    If there are a lot of fields in the record (which admittedly has not yet been established), substr is what I definitely would not use (*yuck*).