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

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.

Replies are listed 'Best First'.
Re^2: Mistake in data structure use?
by McLogic (Initiate) on Dec 01, 2006 at 23:08 UTC
    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.

        You all were right about the error from the beggining. When I use 0=>{} insted of just {}, I make two entries in my array. One entry is "0" and the other is the anon hash (under index 1). When I try to use index 0 as a hash ref, I get my error as index 0 is just "0".