Since you're trying to read in a record, you might consider making a record object. Than you can say something like this to read in a record:
And the new method in the myRecord class would take the filehandle, do some appropriate checks (if it's open, if the first line you read contains the begin block for the record; useful stuff) and store the newly read record in the object. Then you make the typical accessor methods to get at whatever you need, and the object behaves (relatively) like a hash.use myRecord; open FILE, $file or carp "Couldn't open file $file: $!"; while (my $record = new myRecord(\*FILE)) {
The advantages of this style of coding is that if the format ever changes (and it will sometime) you can go into the object and change the way it reads without having to change any part of the rest of the program. It also allows you to sling the records around a little more easily as they're encapsulated.
The disadvantages are that you now have to check the filehandle and you have to write the object in the first place :-)
It's up to you, HTH,
jynx
In reply to Re: how to hash this
by jynx
in thread how to hash this
by malaga
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |