On Wed, Jun 13, 2001 at 06:00:34PM -0400, F.H wrote:
>
> Michael,
> Thanks for taking the time to solve this problem. Of course those are not real ssn
>numbers.
> I tried your suggestion:
>
> ....
> if ($key =~ /^Hobbies/i) {
> push @{$ssns{$ssn}{hobbies}}, [@line[2 .. $#line]];
> }
> }
>
> # print results
> print "\n TEST: $ssns{'123-43-4352'}{'hobbies'}[2][2]\n";
My mistake, this should be:
$ssns{'123-43-4352'}{'hobbies'}[0][2];
The 'H3' hobby is on the third -line-, but on the first -hobby- line.
See:
Name ,123-43-4352, JX, 1234
Sports,123-43-4352, SKI, BaseBall, swimming
Hobbies, 123-43-4352, H1,H2, H3
Hobbies, 123-43-4352, HH, HHH, HHHH2
Hobbies,123-43-4352, H1,H43
> It came out with no results and down below in the foreach loop:
> It printed:
> Hobbies are:
> ARRAY(0xca6840) ARRAY(0xca6828) ARRAY(0xca67f8) ARRAY(0xca67a4)
>
> Did I miss/skip something in the code?
No, you'll need to change your hobbies foreach statement:
print " Hobbies are:\n ";
foreach (sort @{$ssns{$_}{hobbies}}) {
print join(" ", @$_), " ";
}
Now $ssns{$_}{'hobbies'} is a list of lists, so you have to handle it as
such.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--