in reply to Difficult flatfile db record
If the fields are fixed length, you can separate them with unpack. If they are whitespace delimited, split /\s+/ will do to break up the line. Otherwise, you might need a hefty regex. But it looks like they're whitespace delimited, so you could do:open FH, $file or die "Can't open $file: $!"; my @lines = (<FH>)[0,1]; close FH;
There, now you have a hash with all your field names.my %data = (); # define all field names my @line1_fields = qw/ batch_suffix_id associated_operations /; my @lines2_fields = qw/ record_created record_created_date ... /; @data{ @line_1_fileds } = split /\s+/, $lines[0]; @data{ @line_2_fields } = split /\s+/, $lines[1];
--
perl: code of the samurai
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Difficult flatfile db record
by testguy (Initiate) on Sep 16, 2002 at 16:35 UTC | |
by samurai (Monk) on Sep 16, 2002 at 16:54 UTC |