swares has asked for the wisdom of the Perl Monks concerning the following question:
How do I get the right data structure? Here is what the data looks like printed: -- What I Get (BAD) -- [print_rnd_line](^!rob),swares,swares!chatzilla@pendulum-A127A504.wecm +.ibm.com,ARRAY(0x9a9e090),#bots2,{ 'file' => '/home/issuebot/data/rob.txt', },!rob -- What I Need (GOOD) -- [print_rnd_line](^!rob),swares,swares!chatzilla@pendulum-A127A504.wecm +.ibm.com,ARRAY(0x9ab13c8),#bots2,HASH(0x9a4ad0c),!rob [Hal] Got Text [!rob] Here is a code snippet of the offending code: while ((@row) = $sth->fetchrow_array) { $line= join(";", map {defined $_ ? $_ : "(null)"} @row); ($id, $name, $command, $reply_to, $listen_on, $requires, $help +, $description, $sub_name, $args, $sub_code, $whenactive, $enabled, $ +subscribed)=split /;/,$line; print "[load_plugins] Config $id, $name, $command, $reply_to, +$listen_on, $requires, $help, $description, $sub_name, $args, $sub_co +de, $whenactive, $enabled, $subscribed\n"; # subscriber handler my (@subscribed) = split /[\s|\n]+/, $subscribed; foreach my $subscrber (@subscribed){ if ($subscrber =~ /$identity_id/){$subscribed="true";last} +; } if ($subscribed !~ /true/){next}; if ($enabled =~ /true/){ # fix $args hash ref # $args needs to be a reference $public_handlers{"$name"} = ( { id => $id, name => "$name", command => "$command", reply_to => "$reply_to", listen_on => "$listen_on", requires => "$requires", help => "$help", description => "$description", sub => "$sub_name", args => "$args", sub_code => "$sub_code", whenactive => "$whenactive", enabled => "$enabled", }, );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need a hand with rebuilding hashes out of a db.
by Jenda (Abbot) on Apr 04, 2007 at 09:17 UTC | |
by Anno (Deacon) on Apr 04, 2007 at 10:09 UTC |