Perl :: reading values from Data Dumper reference in Perl

Hi all,

I have written a perl code and stored the data into Data structure using Data::Dumper module.
But not sure how to retreive the data from the Data::Dumper.

Eg.

Based on the key value( Here CRYPTO-6-IKMP_MODE_FAILURE I should be able to access the internal hash elements(keys) template and regex.

Could anyone please let me know how to access the inner elements from DataDumper reference.

Tons of thanks...!!!

$VAR1 = {
          'CRYPTO-6-IKMP_MODE_FAILURE' => [
                                            {
                                              'template' => 'Processing of Informational mode failed with peer',
                                              'regex' => 'Processing of Informational mode failed with peer at d{1,3}.d{1,3}.d{1,3}.d{1,3}'
                                            }
                                          ],
          'FWK-3-SOCKET_CLOSE_REMOTE' => [
                                           {
                                             'template' => 'Connection to Mlag',
                                             'regex' => 'Connection to Mlag'
                                           }
                                         ],
          'FWSM-2-106007' => [
                               {
                                 'template' => 'Deny inbound UDP from the IP',
                                 'regex' => 'Deny inbound UDP from d{1,3}.d{1,3}.d{1,3}.d{1,3}/(d)+'
                               },
                               {
                                 'template' => 'Processing of Informational mode failed',
                                 'regex' => 'Processing of Informational mode failed with peer at d{1,3}.d{1,3}.d{1,3}.d{1,3}'
                               }
                             ],
          'CRYPTO-4-IKMP_BAD_MESSAGE' => [
                                           {
                                             'template' => 'Server failed and it is malformed',
                                             'regex' => 'IKE message from d{1,3}.d{1,3}.d{1,3}.d{1,3} failed its sanity check or is malformed'
                                           }
                                         ],
          'FRU-6-TRANSCEIVER_INSERTED' => [
                                            {
                                              'template' => 'A transceiver for interface has been inserted',
                                              'regex' => 'A transceiver for interface (Ethernetd+|Giga)+ has been inserted. manufacturer: Arista Networks model'
                                            }
                                          ],
          'FRU-6-TRANSCEIVER_REMOVED' => [
                                           {
                                             'template' => 'The transceiver for interface has been removed',
                                             'regex' => 'The transceiver for interface [0-z]+/(d)+ has been removed'
                                           }
                                         ],
          'CRYPTO-4-RECVD_PKT_MAC_ERR' => [
                                            {
                                              'template' => 'MAC verify failed for connection',
                                              'regex' => 'decrypt: mac verify failed for connection id=d+ local=d{1,3}.d{1,3}.d{1,3}.d{1,3} remote=d{1,3}.d{1,3}.d{1,3}.d{1,3}'
                                            }
                                          ],
          'CRYPTO-4-IKMP_NO_SA' => [
                                     {
                                       'template' => ' IP has no SA and is not an initialization offer',
                                       'regex' => 'IKE message from d{1,3}.d{1,3}.d{1,3}.d{1,3} has no SA and is not an initialization offer'
                                     }
                                   ]
        };


Regards,
J

Assuming that your hash (data structure) is named %data , you can access "template" using:

$data{'CRYPTO-6-IKMP_MODE_FAILURE'}[0]{'template'}

And "regex":

$data{'CRYPTO-6-IKMP_MODE_FAILURE'}[0]{'regex'}