Perl :: reading values from Data Dumper reference in Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl :: reading values from Data Dumper reference in Perl
# 1  
Old 09-24-2013
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:Smilieumper module.
But not sure how to retreive the data from the Data:Smilieumper.

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...!!!



Code:
$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
# 2  
Old 09-24-2013
Assuming that your hash (data structure) is named %data, you can access "template" using:
Code:
$data{'CRYPTO-6-IKMP_MODE_FAILURE'}[0]{'template'}

And "regex":
Code:
$data{'CRYPTO-6-IKMP_MODE_FAILURE'}[0]{'regex'}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl : reading data from dumper variable

Hi team, # PERL I have Dumper variable in perl and containing the below data and trying to fetch value and name from the reference variable. $VAR1 = { 'retainSysIds' => 'true', 'variables' => , 'name' => , ... (4 Replies)
Discussion started by: giridhar276
4 Replies

2. Shell Programming and Scripting

Perl de-reference code reference variable

Guys, May i know how can we de reference the code reference variable.? my $a = sub{$a=shift;$b=shift;print "SUM:",($a+$b),"\n";}; print $a->(4,5); How can we print the whole function ? Please suggest me regarding this. Thanks for your time :) Cheers, Ranga :) (0 Replies)
Discussion started by: rangarasan
0 Replies

3. Shell Programming and Scripting

AWK, Perl or Shell? Unique strings and their maximum values from 3 column data file

I have a file containing data like so: 2012-01-02 GREEN 4 2012-01-02 GREEN 6 2012-01-02 GREEN 7 2012-01-02 BLUE 4 2012-01-02 BLUE 3 2012-01-02 GREEN 4 2012-01-02 RED 4 2012-01-02 RED 8 2012-01-02 GREEN 4 2012-01-02 YELLOW 5 2012-01-02 YELLOW 2 I can't always predict what the... (4 Replies)
Discussion started by: rich@ardz
4 Replies

4. Shell Programming and Scripting

Perl Script for reading table format data from file.

Hi, i need a perl script which reads the file, content is given below. and output in new file. TARGET DRIVE IO1 IO2 IO3 IO4 IO5 ------------ --------- --------- --------- --------- --------- 0a.1.8 266 236 ... (3 Replies)
Discussion started by: asak
3 Replies

5. Shell Programming and Scripting

Perl: Reading data from other file

Hi, I am writting some perl scripts for daily backup process. In which I want to pass some data/referance from another txt file. Text file contains only one column and multiple rows. I want to pass this data to variables of another perl script. e.g. Refdoc.txt file contains data as: perl1... (3 Replies)
Discussion started by: n.dba
3 Replies

6. Shell Programming and Scripting

Perl Data Structure - Non unique values

I have the perl data structure and what i need to do is find all values in @{$extractColumns{'2'}{'D'}} which are not there in @{$extractColumns{'2'}{'M'}} but seems like i need to put a flag somewhere and i messed up foreach my $order (keys %extractColumns) { foreach my $value... (2 Replies)
Discussion started by: dinjo_jo
2 Replies

7. Shell Programming and Scripting

Reading values in perl

Hi whats the easiest way to read data from a feed file? sample data in a file called data.txt: name = varun ip = '23.43.123.2' address = "asd, blah blah blah ..... @#!$%$#%" i want to use this data in a perl script. I thought of initially reading it line by line n then cutting... (7 Replies)
Discussion started by: VGR
7 Replies

8. Shell Programming and Scripting

perl-extract data from hash values

Hello, I have parsed an xml file using perl to get the hash values and the output looks like this $VAR1 = { 'RT' => { 'List' => { 'String' => ... (1 Reply)
Discussion started by: userscript
1 Replies

9. Shell Programming and Scripting

PERL: reading 2 column data into Hash file

I am trying to read in a 2 column data file into Perl Hash array index. Here is my code. #!/usr/bin/perl -w use strict; use warnings; my $file = "file_a"; my @line = (); my $index = 0; my %ind_file = (); open(FILE, $file) or die($!); while(<FILE>) { chomp($_); if ($_ eq '') { ... (1 Reply)
Discussion started by: subhap
1 Replies

10. Shell Programming and Scripting

Reading data into muti-dimentional array - in perl

Just want to learn how these are read into array but I don't seem to get it right what do I go wrong? Below is the sample Thanks input 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 #!/usr/bin/perl open (InFILE,"input"); while (<InFILE>) { @ar = split ; (5 Replies)
Discussion started by: zap
5 Replies
Login or Register to Ask a Question