NothingInCommon has asked for the wisdom of the Perl Monks concerning the following question:
Resulting Data structure output# Code that builds the structure while ( my $line = <DATA> ) { chomp $line; if ( $line =~ m/^BS:\s+(\S+)/ ) { $result{$1} = { %queue }; %queue = (); } else { my ( $name, $in_percent, $in_num, $out_percent, $out_num ) = split m{ \(| / | of 1024 \| event | of 1024\)}, $line; $queue{$name} = { in_q_per => $in_percent, in_q_num => $in_num, out_q_per => $out_percent, out_q_num => $out_num, }; } }
The code worked perfectly and when you print Data::Dumper it prints it out like it shows above. I have been trying to get this data structure into a mysql database for days with out much luck Can you give me some examples of how I can get it into a table like the one below. Ive already tried a foreach within a foreach but each time the I get stuff like this HASH(0x9c9d628) inserted.# Resulting Data structure output '111_DDD,' => { 'AAA_AA2_DDD' => { 'in_q_per' => '0%', 'in_q_num' => '0%', 'out_q_per' => '0', 'out_q_num' => '0' }, 'AAA_AA1_DDD' => { 'in_q_per' => '0%', 'in_q_num' => '0%', 'out_q_per' => '0', 'out_q_num' => '0' }, ...etc...
#MYSQL TABLE BS queue_name in_q_per in_q_num out_q_per out_q_num ------------------------------------------------------------ 111_DDD AAA_AA1_DDD 0% 0 0% 0 111_DDD AAA_AA2_DDD 0% 0 0% 0 222_DDD BBB_BB1_DDD 0% 0 0% 0 222_DDD BBB_BB1_DDD 0% 0 0% 0 333_DDD CCC_CC1_DDD 0% 0 0% 0 333_DDD CCC_CC1_DDD 0% 0 0% 0
__DATA INPUT__ AAA_AA1_DDD (0% / 0 of 1024 | event 0% / 0 of 1024) AAA_AA2_DDD (0% / 0 of 1024 | event 0% / 0 of 1024) BS: 111_DDD, QE: QQQ_DDD (additionnal QE) BBB_BB1_DDD (0% / 0 of 1024 | event 0% / 0 of 1024) BBB_BB2_DDD (0% / 0 of 1024 | event 0% / 0 of 1024) BS: 222_DDD, QE: QQQ_DDD (additionnal QE) CCC_CC1_DDD (0% / 0 of 1024 | event 0% / 0 of 1024) CCC_CC2_DDD (0% / 0 of 1024 | event 0% / 0 of 1024) BS: 333_DDD, QE: QQQ_DDD (additionnal QE)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash of Hash to mysql
by graff (Chancellor) on Apr 27, 2009 at 01:31 UTC | |
|
Re: Hash of Hash to mysql
by sflitman (Hermit) on Apr 26, 2009 at 21:22 UTC |