HoH deletion problem after 5.6.1 to 5.8.4 upgrade

Discussion in 'Perl Misc' started by woodenbicycle@hotmail.com, May 2, 2005.

  1. Guest

    Help! I am just a perl tinkerer who doesn't know much about data
    strctures. I am having a problem with a little pet project of mine.
    Please take a look and help me if you have time.

    I upgraded from 5.6.1 to 5.8.4 and now some of my old code now seems to
    be broken. I have been banging my head over this over the weekend and I
    think the problem has to do with the way I am deleting an item from my
    Hash of Hashes.

    I have the code segment below. "HoH" is the Hash of Hashes. "key_list"
    is a list of the keys in HoH. "selected" is the index number of the
    item I wish to delete from the HoH via the key_list.

    0-50: ### Obtain $selected by a Perl/Tk scrolled listbox and button
    51: print "running...\n";
    52: my $key = $key_list[$selected];
    53: print "delete item# $key\n";
    54: delete $HoH{$key};
    55: $key_list[$selected] = '0';
    56+: ### Build new key_list with a simple loop

    I get the following to the console when code is run:
    running...
    delete list# ARRAY(0x85089a8)
    Use of reference "ARRAY(0x85089a8)" as array index at testcase.pl line
    52.
    Use of uninitialized value in concatenation (.) or string at
    testcase.pl line 53.
    delete item#
    Use of uninitialized value in delete at testcase.pl line 54.
    Use of reference "ARRAY(0x85089a8)" as array index at testcase.pl line
    55.
    Out of memory!
    Callback called exit.
    Callback called exit.
    Segmentation fault

    This code seems to work fine under 5.6.1 but does not work under 5.8.4.
    I thank you now for your help!

    Pepper
     
    , May 2, 2005
    #1
    1. Advertising

  2. Guest

    wrote:
    > Help! I am just a perl tinkerer who doesn't know much about data
    > strctures. I am having a problem with a little pet project of mine.
    > Please take a look and help me if you have time.
    >
    > I upgraded from 5.6.1 to 5.8.4 and now some of my old code now seems to
    > be broken. I have been banging my head over this over the weekend and I
    > think the problem has to do with the way I am deleting an item from my
    > Hash of Hashes.


    I don't think that that is your problem. The problem is probably
    earlier (when $selected is getting set to an arrayref rather than an
    integer) or later (When you run out of memory and die, apparently
    in a part of the code you don't show.)


    > I have the code segment below. "HoH" is the Hash of Hashes. "key_list"
    > is a list of the keys in HoH. "selected" is the index number of the
    > item I wish to delete from the HoH via the key_list.


    No, it isn't. Acccording the output generated by line 53, $selected
    is ARRAY(0x85089a8).

    >
    > 0-50: ### Obtain $selected by a Perl/Tk scrolled listbox and button
    > 51: print "running...\n";
    > 52: my $key = $key_list[$selected];
    > 53: print "delete item# $key\n";
    > 54: delete $HoH{$key};
    > 55: $key_list[$selected] = '0';
    > 56+: ### Build new key_list with a simple loop
    >
    > I get the following to the console when code is run:


    What did you get as output back under 5.6.1 when the code
    was working?

    > running...
    > delete list# ARRAY(0x85089a8)
    > Use of reference "ARRAY(0x85089a8)" as array index at testcase.pl line
    > 52.


    Looks like GIGO to me. Figure out why the garbage is getting in.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , May 2, 2005
    #2
    1. Advertising

  3. Guest

    I obtain $selected on line 50, which looks like this:
    50: my $selected = $viewlist->curselection;

    "viewlist" is my scrolled listbox (Perl/Tk) which I define and fill
    like this:
    37: $viewlist = $viewframe->Scrolled("Listbox", -scrollbars => 'e',
    -width => 32, -height => 5, -selectmode => 'single')->pack(-side =>
    'top');
    38: $viewlist->insert('end', "Item 0");
    39: $viewlist->insert('end', "Item 1");

    I added a line right below line 50 to ouput the value of $selected the
    moment it is obtained:
    51: print "$selected\n";

    With Perl 5.6.1 running the Tk module 800.024 (Debian Woody Stable),
    the output of that line is the integer "1"

    With Perl 5.8.4 running the Tk module 800.025 (Debian Sarge Testing),
    the output of that line is the array reference show in the output in my
    initial post.

    I'm baffled and will rephrase my question and post it in
    comp.lang.perl.tk.

    Pepper
     
    , May 2, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Greenfield

    HoH and MLDBM problems

    Brian Greenfield, Aug 26, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    166
    Bob Walton
    Sep 17, 2003
  2. Aaron DeLoach

    HoHoH (hash of HoH's)

    Aaron DeLoach, Jul 18, 2004, in forum: Perl Misc
    Replies:
    10
    Views:
    185
    Aaron DeLoach
    Jul 20, 2004
  3. Replies:
    1
    Views:
    122
    Gunnar Hjalmarsson
    Jan 17, 2005
  4. lynn
    Replies:
    5
    Views:
    131
    John W. Krahn
    Jul 12, 2005
  5. Replies:
    6
    Views:
    143
Loading...

Share This Page