use warnings;
use strict;
use Data::Dump::Streamer;
my %records;
while (! eof (DATA)) {
my $line1 = <DATA>;
next unless defined $line1 and $line1 =~ /^\s1/;
$_ = <DATA> for my ($line2, $line3, $line4, $line5);
my $id = substr $line1, 9, 5;
$records{$id} = [$line1, $line2, $line3, $line4, $line5];
}
Dump (\%records);
__DATA__
10101ABC000019101L0001374686047S30339 GA &DOE C080229CR7 7
+00244 0000001 000000000
2 CR7 000 060714Q
+ Y 0000000000 000
3 00030339 3JO
+HN DOE 36
423 MAIN STREET ATLANTA GA 30339
5 +000000000
+0080226I 052461 05241961
10101ABC000029102 N D
+3658 MAIN STREET
2 ATLANTA GA3033
+9 0001
3JOHN DOE 05241961INDV37468604
+7S
4
5
Prints:
$HASH1 = {
"00001" => [
" 10101ABC000019101L0001374686047S30339 GA
+&DOE C080229CR7 7 00".
"244 0000001 000000000\n",
" 2 CR7 000 060
+714Q ".
" Y 0000000000 000\n",
" 3 00030339
+ 3JOHN".
" DOE 36\n",
" 423 MAIN STREET ATLANTA GA 3
+0339\n",
" 5
+ +00000000000".
"80226I 052461 05241961\n"
],
"00002" => [
" 10101ABC000029102 N D
+ 36".
"58 MAIN STREET\n",
" 2 ATLANTA
+ GA30339 ".
" 0001\n",
" 3JOHN DOE
+ 05241961INDV374686047S".
"\n",
" 4\n",
" 5\n"
]
};
Note that I edited the second record to give it a unique id as described and that I restored what appeared to be a missing space in front of the first line of the first record.
Perl reduces RSI - it saves typing
|