Mysterious extra hashtable entry

Posted by Harm De Weirdt on Stack Overflow See other posts from Stack Overflow or by Harm De Weirdt
Published on 2010-03-23T19:52:59Z Indexed on 2010/03/23 20:03 UTC
Read the original article Hit count: 356

Filed under:
|
|

Good evening everyone, I'm back :)

Let me explain my problem. I have a hashtable in wich I store the products a costumors buys (%orders). It uses the productcode as key and has a reference to an array with the other info as value.

At the end of the program, I have to rewrite the inventory to the updated version (i.e. subtract the quantity of the bought items)

This is how I do this:

sub rewriteInventory{
    open(FILE,'>inv.txt');
    foreach $key(%inventory){
        print FILE "$key\|$inventory{$key}[0]\|$inventory{$key}[1]\|$inventory{$key}[2]\n"
    }
    close(FILE);
}

where $inventory{$key}[x] is 0 -> Title, 1 -> price, 2 -> quantity. The problem here is that when I look at inv.txt afterwards, I see things like this:

CD-911|Lady Gaga - The Fame|15.99|21
ARRAY(0x145030c)|||
BOOK-1453|The Da Vinci Code - Dan Brown|14.75|12
ARRAY(0x145bee4)|||

Where do these "ARRAY(0x145030c)|||" entries come from? Or more important, how do I get rid of them? This is the last part of this school task, I had so much problems programming all this and this stupid little thing comes up now and I'm really fed up with this whole Perl thing. (this aside :p)

I hope someone can help me :)

Fuji

© Stack Overflow or respective owner

Related posts about perl

Related posts about hashtable