Hi guys, I am using DBM::Deep to store some fairly large and complex hashes in databases. I use them to store information for 324 Set Top Boxes. These are separated in to 9 Zones of 36 STBs. In the hash (.db file) each box is a key and the values are a hash of further key/value pairs, for example:

Z1-B1 => { 'Moxa IP Address => '192.168.1.2', 'Moxa Port => '4001', 'Dusky Port => '01' };

This layout is repeated for all 324 STBs. I have some more databases which store hashes where Groups are defined as the key, and a list of STBs within that group are stored as an array in the value, for example:

'Group 1' => [Z1-B1,Z2-B1,Z3-B1,Z4-B1]

We use this information to get data for each STB so that we can control it using IO::Socket::Inet. Sometimes we control groups of STBs at a time, for example sending power on to all STBs in the group "Zone 1". This group would contain 36 STBs. The script iterates through each box in the group, retrieves their control details from the hash database, and then issues commands to them using that data.

My problem is that when I choose to control a large number of boxes in one go e.g, the group Zone 1 (36 boxes), I sometimes get an error of "Can't use an undefined value as a symbol reference at my_script.pl line xxx"

This error sometimes doesn't happen at all, but when it does, it is not in the same place. The line in the code it refers to is where a connection is made through IO::Socket::Inet. Below is a snippet of my code:

my $duskyip = $controls{"$stb"}{'DuskyMoxaIP'}; my $duskymoxaport = $controls{"$stb"}{'DuskyMoxaPort'}; my $dusky = new IO::Socket::INET(PeerAddr => $duskyip, PeerPort =>$dus +kymoxaport, Proto => 'tcp', Timeout => 1); my $duskyport = $controls{"$stb"}{'DuskyPort'}; my $fullcom = "A+$duskyport$rawcmd$closebit"; print $dusky $fullcom; #### LINE THAT ERROR REFERS TO ####

My first thought is that it doesn't retrieve the details needed from the database quick enough to create the IO::Socket::Inet connection. I am currently accessing the database files as follows:

tie %controls, 'DBM::Deep', {file => '/var/www/cgi-bin/Database/E2E_STB_Control_Data.db',locking => 1, autoflush => 1, num_txns => 100};

The "num_txns" option was added in to see if it helped but it doesn't. Any ideas or suggestions will be greatly appreciated.

Thanks


In reply to Fast database access using DBM::Deep help by Doozer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.