in reply to Re: Mistake in data structure use?
in thread Mistake in data structure use?

The part you quote and say I should change is the dump from Data::Dumper, the code is above that.

I do really need help with this one, I worked on it all last night, but I think it is just something that I don't know and need to be pointed in the right direction.

Replies are listed 'Best First'.
Re: Mistake in data structure use?
by jonadab (Parson) on Dec 01, 2006 at 22:40 UTC

    Data::Dumper does it like that because your code does it like that:

    school=>[ 0=>{school_type=>"school", school_name=>undef, graduation_da +te=>undef}, 1=>{school_type=>"school1", school_name=>undef, graduation_d +ate=>undef}, ],

    The other poster is suggesting you do it this way:

    school=>[ {school_type=>"school", school_name=>undef, graduation_date=> +undef}, {school_type=>"school1", school_name=>undef, graduation_date= +>undef}, ],

    However, if that's not the problem, perhaps you should tell us which line exactly is line 136. I could not tell this easily from your original post. perl's error messages tell you the line number for a reason.


    Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. You can just call me "Mister Sanity". Why, I've got so much sanity it's driving me crazy.
      line 136 is this one from the code block:
      $member_info{'person'}[0]{'salutation'} = &skip_to_cell_text( +1 ); # error on this line

      It is the first time I try to assign something to a spot in the structure.

        The error message is exactly right. The first element of the array reference you've assigned to person is the value 0, which is not a hash reference. It's a plain scalar value. In Perl, you don't assign pairs of indices and values to arrays. Perl will automatically use the correct index numbers when you assign a list to an array.

        Do what the first commenter suggested and your code will work better.