If you are sure that every 5 lines is a record, you might just read 5 lines and get the user id from the first line. As a safety mechanism you could test wether the uid line has a string of at least 15 non-space characters at the beginning.
Better would be to check for the uid line, but is there anything in the uid line that can't occur on any other line? Maybe that the user id line starts with 5 numeric digits, then 3 alpha digits. This could be tested with if ($line=~/^\d{5}[a-zA-Z]{3}\w{6}/) { ....
If you have something to identify the line, the following (untested) code might work
my %allids=(); my $quo=''; while (my $line=<INP>) { if ($line=~ ... ) { $allids{substr($quo->[0],8,6)}= $quo if $quo; $quo=[$line]; } else { push @$quo, $line; } }
After that you should be able to access the array of lines for id 000123 with @{$allids{'000123'}}
UPDATE: PS: You say that substr 9-14 is the id, but in your example both records have the same numbers in the columns 9 to 14 (no matter if you counted from 0 or 1).
In reply to Re: Hash Help
by jethro
in thread Hash Help
by mmittiga17
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |