Hey Monks, I have an issue you can probably maybe help me with. I have a piece of code that seems not being working for just one random value... As we all know that random results and programming are barely compatible, I am seeking advices to help me troubleshoot the code bellow.

%ulm_msg : just raw ULM messages. Example in the output bellow.

@ulm_tags : contain MSGTYPE GCCI.PRODUCT.FLOW EXECSERVPRODUCT

All the others values are initialized in the code bellow:

------------------------------------

# Creation of a hash of anonymous hash # Model is : KeyTag => { KeyVal => Frequency } # Example: 35 => { D => 10 } # 35 => { G => 3 } foreach $h_tag (@ulm_tags){ $ulm_keys{$h_tag}{"FAKE"} = "FAKE"; # [ULM TAGS]: [ MSGTYPE | GCCI.PRODUCT.FLOW | EXECSERV +PRODUCT ] # %ULM KEYS: GCCI.PRODUCT.FLOW => { 1 => 1 } # %ULM KEYS: MSGTYPE => { 1 => 1 } } # Populating the hash of anonymous hash while (($key, $value) = each(%ulm_msg)) { foreach $h_tag (keys %ulm_keys) { if($value =~ /$h_tag/){ $value =~ /\|$h_tag=([ +^|]*)/; $h_val = $1; printf "\nh_tag:h_val +=> ".$h_tag.":".$h_val."\n"; if(exists $ulm_keys{$h +_tag}{$h_val}){ $ulm_k +eys{$h_tag}{$h_val} => $ulm_keys{$h_tag}{$h_val}++; printf + "Incrementing a hash entry: ".$h_tag.":".$h_val."=>".$ulm_keys{$h_ta +g}{$h_val}."\n"; } else{ $ulm_k +eys{ $h_tag } = { + $h_val => 1, }; printf + "Adding a new hash entry: ".$h_tag.":".$h_val."=>".$ulm_keys{$h_tag} +{$h_val}."\n"; if($h_ +val eq "AQUA"){ + printf "ULM: ".$value."\n"; } } } } } # Display the Hash printf "\n\nHASH OF HASH\n\n"; for $h_tag ( keys %ulm_keys ) { print "$h_tag: "; for $h_val ( keys %{ $ulm_keys{$h_tag} } ) { print "$h_val=$ulm_keys{$h_tag}{$h_va +l} "; } print "\n"; }

------------------------------------

So this piece of code seems to be absolutely fine. Except one thing, for just one value the line : if(exists $ulm_keys{$h_tag}{$h_val}){....

Seems to not be true, meaning we are recreating an existing key/pair. I do not understand why. Bellow an extract of the output, that can help to spot the issue and understand the content of each variable:

h_tag:h_val => MSGTYPE:new Incrementing a hash entry: MSGTYPE:new=>12 h_tag:h_val => EXECSERVPRODUCT:ARID Adding a new hash entry: EXECSERVPRODUCT:ARID=>1 h_tag:h_val => GCCI.PRODUCT.FLOW:ATS Incrementing a hash entry: GCCI.PRODUCT.FLOW:ATS=>13 h_tag:h_val => MSGTYPE:new Incrementing a hash entry: MSGTYPE:new=>13 h_tag:h_val => EXECSERVPRODUCT:TWAP Adding a new hash entry: EXECSERVPRODUCT:TWAP=>1 h_tag:h_val => GCCI.PRODUCT.FLOW:ATS Incrementing a hash entry: GCCI.PRODUCT.FLOW:ATS=>14 h_tag:h_val => MSGTYPE:new Incrementing a hash entry: MSGTYPE:new=>14 h_tag:h_val => EXECSERVPRODUCT:CLOSE Adding a new hash entry: EXECSERVPRODUCT:CLOSE=>1 h_tag:h_val => GCCI.PRODUCT.FLOW:ATS Incrementing a hash entry: GCCI.PRODUCT.FLOW:ATS=>15 h_tag:h_val => MSGTYPE:new Incrementing a hash entry: MSGTYPE:new=>15 h_tag:h_val => EXECSERVPRODUCT:AQUA Adding a new hash entry: EXECSERVPRODUCT:AQUA=>1 ULM: 8=FIX.4.2|9=898|35=UL|49=EMC01|56=EMSECS|34=6007|52=20120221-09:5 +9:47|212=831|#EXDESTINATION=L|#GCCI.PRODUCT.EXECUTION_REGION=EMEA|#GC +CI.PRODUCT.EXECUTION_SUB_REGION=EMEA|#IDSOURCE=5|#ONBEHALFOFCOMPID=P2 +|#SECURITYID=VOD.L|#SYMBOL=VOD.L|CLORDID=GGPHCJP9459dd|CREATIONTIME=2 +0120221095947|EXDESTINATION=L|EXECSERVPRODUCT=AQUA|GCCI.CLIENT.COMPID +=P2|GCCI.CLIENT.FIXSESSION=TEST_|GCCI.INSTRUMENT.REUTERS_EXCHANGE=L|G +CCI.PRODUCT.EXECUTION_REGION=EMEA|GCCI.PRODUCT.EXECUTION_SUB_REGION=E +MEA|GCCI.PRODUCT.FLOW=ATS|HANDLINST=care|MSGTYPE=new|ONBEHALFOFCOMPID +=P2|ORDERQTY=1|ORDSTATUS=pendingnew|ORDTYPE=market|PLUGINORIGINATOR=T +EST__GEN|PLUGINOWNER=TEST__GEN|RICCODE=VOD.L|ROOTCLIENTORDERID=JP9459 +dd|SENDERCOMPID=TEST_|SIDE=buy|SYMBOL=VOD.L|TARGETCOMPID=_|TIMEINFORC +E=day|TRANSACTTIME=20120221095945806|ULFROMSESSIONNAME=TEST__GEN|ULTO +SESSIONNAME=PULM_EMC01_EMSECS||10=219| h_tag:h_val => GCCI.PRODUCT.FLOW:ATS Incrementing a hash entry: GCCI.PRODUCT.FLOW:ATS=>16 h_tag:h_val => MSGTYPE:new Incrementing a hash entry: MSGTYPE:new=>16 h_tag:h_val => EXECSERVPRODUCT:TWAP Adding a new hash entry: EXECSERVPRODUCT:TWAP=>1 h_tag:h_val => GCCI.PRODUCT.FLOW:ATS Incrementing a hash entry: GCCI.PRODUCT.FLOW:ATS=>17 h_tag:h_val => MSGTYPE:new Incrementing a hash entry: MSGTYPE:new=>17 h_tag:h_val => EXECSERVPRODUCT:AQUA Adding a new hash entry: EXECSERVPRODUCT:AQUA=>1 ULM: 8=FIX.4.2|9=898|35=UL|49=EMC01|56=EMSECS|34=6009|52=20120221-09:5 +9:47|212=831|#EXDESTINATION=L|#GCCI.PRODUCT.EXECUTION_REGION=EMEA|#GC +CI.PRODUCT.EXECUTION_SUB_REGION=EMEA|#IDSOURCE=5|#ONBEHALFOFCOMPID=_P +4|#SECURITYID=VOD.L|#SYMBOL=VOD.L|CLORDID=GGPHCJP9461dd|CREATIONTIME= +20120221095947|EXDESTINATION=L|EXECSERVPRODUCT=AQUA|GCCI.CLIENT.COMPI +D=_P4|GCCI.CLIENT.FIXSESSION=TEST_|GCCI.INSTRUMENT.REUTERS_EXCHANGE=L +|GCCI.PRODUCT.EXECUTION_REGION=EMEA|GCCI.PRODUCT.EXECUTION_SUB_REGION +=EMEA|GCCI.PRODUCT.FLOW=ATS|HANDLINST=care|MSGTYPE=new|ONBEHALFOFCOMP +ID=_P4|ORDERQTY=1|ORDSTATUS=pendingnew|ORDTYPE=market|PLUGINORIGINATO +R=TEST__GEN|PLUGINOWNER=TEST__GEN|RICCODE=VOD.L|ROOTCLIENTORDERID=JP9 +461dd|SENDERCOMPID=TEST_|SIDE=buy|SYMBOL=VOD.L|TARGETCOMPID=|TIMEINFO +RCE=day|TRANSACTTIME=20120221095945806|ULFROMSESSIONNAME=TEST__GEN|UL +TOSESSIONNAME=PULM_EMC01_EMSECS||10=213| HASH OF HASH! GCCI.PRODUCT.FLOW: ATS=17 MSGTYPE: new=17 EXECSERVPRODUCT: AQUA=1
---------------------------------------------------------

As you can see the key/pair => EXECSERVPRODUCT:AQUA is added more than one time. All the others key/pairs seems to be fine. Any idea why ?


In reply to Hash of hash check if defined by Jup

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.