Sponsored Content
Top Forums Shell Programming and Scripting Perl : to get the no. of elements from DataDumper Post 302860027 by scriptscript on Friday 4th of October 2013 12:26:49 PM
Old 10-04-2013
Perl : to get the no. of elements from DataDumper

Hello Folks,

I have a DataDumper variable and the output of the dataDumper is printed in the below manner.
Code:
print Dumper \%mnemonics;

VAR1 = {
 
          'SYS-7-CLI_SCHEDULER_LOG_STORED' => [
                                                {
                                                  'template' => 'Logfile for scheduled CLI execution job is stored in flash memory',
                                                  'regex' => 'Logfile for scheduled CLI execution job \'tech-support\' is stored in flash memory',
                                                  'trap' => '5'
                                                }
                                              ],
          'CRYPTO-6-IKMP_MODE_FAILURE' => [
                                            {
                                              'template' => 'Processing of Informational mode failed with peer IP',
                                              'regex' => 'Processing of Informational mode failed with peer at (\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})',
                                              'trap' => '4'
                                            }
                                          ],
          'AAAA-4-SERVUNDEF' => [
                                  {
                                    'template' => 'The server-group "vty" is not defined. Please define it.',
                                    'regex' => 'The server-group "vty" is not defined. Please define it.',
                                    'trap' => '1'
                                  }
                                ],
          'FWSM-2-106007' => [
                               {
                                 'template' => 'Deny inbound UDP from the IP Address',
                                 'regex' => 'Deny inbound UDP from (\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})',
                                 'trap' => '8'
                               },
                               {
                                 '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})',
                                 'trap' => '9'
                               }
                             ]
        };

Now I want to get the no. of elements in the particular hash element.

Suppose say , I want to get the no. of elements that 'FWSM-2-106007' is points towards .

i.e., 2

So 2 has to be the output.

Example 2 : 'CRYPTO-6-IKMP_MODE_FAILURE' is pointing towards only one array elments. So the no. of elements is 1.


Could anyone please let me know to get the no. of elments that hash is referencing towards .

Regards,
J
 

9 More Discussions You Might Find Interesting

1. AIX

How to list mirrored elements? (pv, vg, lv)

Hello, How can I list mirrored elements, such as PV, VG or LV? (and others if applicable). On AIX 4.3.3 and 5.3.0. I tried the commands: lscfg|grep hd lspv lsvg lsvg -l (of each vg) lslv (and some options) But could not find what am I looking for. I saw a "number of copies", but I am... (4 Replies)
Discussion started by: cactux
4 Replies

2. Shell Programming and Scripting

Perl - New line in array elements

Hello, I have a comma delimited input feed file. The first field has directory location and the second field has file name. Ex of input feed: /export/appl/a,abc*.dat /export/appl/b,xyz*.dat /export/appl/c,pmn*.dat Under each directory, there would be many files like... . . .... (4 Replies)
Discussion started by: bperl
4 Replies

3. Shell Programming and Scripting

just want certail elements

I just want to be able to take every 6 value out of an arrays can someone tell me what i'm doing wrong? the data looks like 1500680,Treverbyn,397,1,2136,4420 and i want the 2 element treverbyn out of every row #hour0.pl my $url = 'http://en19.tribalwars.net/map/tribe.txt'; use... (1 Reply)
Discussion started by: frenchface
1 Replies

4. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

5. Shell Programming and Scripting

Perl:Use of array elements in pattern matching

I need to use array elements while pattern matching. @myarr = (ELEM1, ELEM2, ELEM3); following is the statement which I am using in my code. Basically I want to replace the ELEM1/2/3 with other thing which is mentioned as REPL here. if (condition) { s/(ELEM1|ELEM2|ELEM3): REPL: /; } I... (3 Replies)
Discussion started by: deo_kaustubh
3 Replies

6. Shell Programming and Scripting

Perl Array Elements Replacement

Hello, I have the following perl array: @longname = (Fasthernet0/0 Fasthernet0/1 Serial0/1/0 Serial0/2/1 Tunnel55 Tunnel77) with the followinh array: @shortname = (Fa0/0 Fa0/1 Se0/1/0 Se0/2/1 Tu55 Tu77) in other words, I need to remove the following from each element in the array... (4 Replies)
Discussion started by: ahmed_zaher
4 Replies

7. UNIX for Dummies Questions & Answers

Help with editing string elements

Hi All I have a question. I would like to edit some string characters by replacing with characters of choice located in another file. For example in sample file>S5_SK1.chr01 NNNNNNNNNNNNNNNNNNNCAGCATGCAATAAGGTGACATAGATATACCCACACACCACACCCTAACACTAACCCTAATCTAACCCTGGCCAACCTGTTT... (9 Replies)
Discussion started by: pawannoel
9 Replies

8. Shell Programming and Scripting

Array elements comparison using perl

Experts, I am looking to compare elements of 2 array using perl. Below is not the actual code but logic wise something like this. my $version = "MYSQlcl-5.2.4-264.x86_64"; <-- split this word into array as (5 2 4 264) ( which is to extract only the version number from the package name) my... (1 Reply)
Discussion started by: solaix14
1 Replies

9. Shell Programming and Scripting

Perl : converting file to different scalar elements

I have a text file containing 2 exec statements as below and trying to store the below 2 execs into 2 different scalar variables in perl. /* ICD Dist, Total */ /* need to export to Excel, sheet=ICD_Dist__Total */ exec( 'select sum(count(*)) cast(count(*)*100.0/sum(count(*)) over() as... (7 Replies)
Discussion started by: scriptscript
7 Replies
bup-margin(1)						      General Commands Manual						     bup-margin(1)

NAME
bup-margin - figure out your deduplication safety margin SYNOPSIS
bup margin [options...] DESCRIPTION
bup margin iterates through all objects in your bup repository, calculating the largest number of prefix bits shared between any two entries. This number, n, identifies the longest subset of SHA-1 you could use and still encounter a collision between your object ids. For example, one system that was tested had a collection of 11 million objects (70 GB), and bup margin returned 45. That means a 46-bit hash would be sufficient to avoid all collisions among that set of objects; each object in that repository could be uniquely identified by its first 46 bits. The number of bits needed seems to increase by about 1 or 2 for every doubling of the number of objects. Since SHA-1 hashes have 160 bits, that leaves 115 bits of margin. Of course, because SHA-1 hashes are essentially random, it's theoretically possible to use many more bits with far fewer objects. If you're paranoid about the possibility of SHA-1 collisions, you can monitor your repository by running bup margin occasionally to see if you're getting dangerously close to 160 bits. OPTIONS
--predict Guess the offset into each index file where a particular object will appear, and report the maximum deviation of the correct answer from the guess. This is potentially useful for tuning an interpolation search algorithm. --ignore-midx don't use .midx files, use only .idx files. This is only really useful when used with --predict. EXAMPLE
$ bup margin Reading indexes: 100.00% (1612581/1612581), done. 40 40 matching prefix bits 1.94 bits per doubling 120 bits (61.86 doublings) remaining 4.19338e+18 times larger is possible Everyone on earth could have 625878182 data sets like yours, all in one repository, and we would expect 1 object collision. $ bup margin --predict PackIdxList: using 1 index. Reading indexes: 100.00% (1612581/1612581), done. 915 of 1612581 (0.057%) SEE ALSO
bup-midx(1), bup-save(1) BUP
Part of the bup(1) suite. AUTHORS
Avery Pennarun <apenwarr@gmail.com>. Bup unknown- bup-margin(1)
All times are GMT -4. The time now is 08:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy