Perl : array of hashes help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl : array of hashes help
# 1  
Old 04-30-2012
Perl : array of hashes help

Hi,

I have array of hashes and each key has array like below.
Code:
   @array1 = (
         
          {
            'url' => [
                       't/uploads/2012/04/HB-177-Veto-Letter.pdf'
                     ],
            'bill' => [
                        'CS3',
                        'HB',
                        '177',
                        'Inmate Reentry',
                        'Porth',
                        '3/9/12',
                        '3/30/12',
                        'VETO'
                      ]
          },
          {
            'url' => [
                       'ads/2012/03/3.29.12-Transmittal-Letter-3.pdf'
                     ],
            'bill' => [
                        'CS1',
                        'HB',
                        '697',
                        'Relief/Donald Brown/District School Board of Sumter County',
                        'McBurney',
                        '3/9/12',
                        '3/16/12',
                        'VETO'
                      ]
          },
          {
            'url' => [
                       '/HB-865-Veto-Letter.pdf'
                     ],
            'bill' => [
                        '',
                        'HB',
                        '865',
                        'Pinellas Suncoast Transit Authority, Pinellas County',
                        'Hooper',
                        '3/9/12',
                        '3/30/12',
                        'VETO'
                      ]
          },
          {
            'url' => [
                       '/2012/04/4.13.12-HB-917-Veto-Letter.pdf'
                     ],
            'bill' => [
                        '',
                        'HB',
                        '917',
                        'Jurisdiction of the Courts',
                        'Bileca',
                        '3/7/12',
                        '3/30/12',
                        'VETO'
                      ]
          },
          {
            'url' => [
                       'ads/2012/04/HB-1117-Veto-Letter.pdf'
                     ],
            'bill' => [
                        'CS1',
                        'HB',
                        '1117',
                        'Conservation of Wildlife',
                        'Harrison',
                        '3/9/12',
                        '3/30/12',
                        'VETO'
                      ]
          }
 
        );

Now from the above array i want to grep for 1117 which should be value of key 'bill' of the different hashes.. i can do that using for loop, but i hope there would be some one liner to grep all those hashes into an array whose 'bill' key value contains 1117..

so please help me here ...

thanks in Advance
Sridhar

Moderator's Comments:
Mod Comment Please use next time code tags for your code and data

Last edited by vbe; 04-30-2012 at 12:39 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl hash of hashes anonymous array

Hello experts. I'm having problems with a snippet of code. I was hoping to get help/advice to correct. A file that this script parses has changed to the point where I can no longer use a scalar, it looks as though I need to create an array for a hash of hashes below. The first output of... (1 Reply)
Discussion started by: timj123
1 Replies

2. Shell Programming and Scripting

perl: dereferencing a hash of hashes

Hi there, I am trying to dereference my hash of hashes but post dereferencing, it seems to lose its structure I am using Data::dumper to help me anaylise. This is the code im using to build the HoH, (data comes from a file). I have also performed a Dumper on the data structure before and after... (1 Reply)
Discussion started by: rethink
1 Replies

3. Shell Programming and Scripting

Creating Hashes of Hashes of Array

Hi folks, I have a structure as mentioned below in a configuration file. <Component> Comp1: { item1:data,someUniqueAttribute; item2:data,someUniqueAttribute, } Comp2: { item3:data,someUniqueAttribute; ... (1 Reply)
Discussion started by: ckv84
1 Replies

4. Shell Programming and Scripting

PERL - another quick hash of hashes question

Hi, sorry, two hash related questions in one day .. but this has got me a bit stuck. I have a mysql database table that kind of looks like this, the table is called "view1" and a snippet of that table (SELECT'ing just rows with serial number 0629AN1200) is below serial nic_name ... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

5. Shell Programming and Scripting

perl hash of hashes from database

hi there, I have some database output that looks like this SELECT nic_name,nic_duplex,nic_speed,nic_ip FROM network_table WHERE hostname = "server1" result is this (ive delimited with a pipe for ease of reading) bge0|full|1000|10.32.100.1 bge1|full|1000|11.12.101.7 ... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

6. Shell Programming and Scripting

Hashes help in Perl

Hi, I am stuck at this problem where part of my code would store all the websites that has been accessed by a user. I pull these values from a log file. I want to create a HASH of HASHES ? (Please correct me if this is not the right approach) where I would store all the hits to website with... (4 Replies)
Discussion started by: Dabheeruz
4 Replies

7. Shell Programming and Scripting

Array split function & hashes

Hi, If this is the array that is being returned to me: How would I get the values for each of the 3 records? This works for 1 Record: foreach $item (@results) { ($id, $id2, $name, $date, $email) = split(/\|/, $item, 5); print "$name<br>"; } (2 Replies)
Discussion started by: novera
2 Replies

8. Shell Programming and Scripting

perl hashes question

hi guys im running into a problem here this is my script #!/usr/bin/perl use CGI qw(:standard); $header = "MIME-Version: 1.0\n"; $header .= "Content-type: text/html\n"; $header .= "\n"; #get the point parameter from nhl.html $Team = param("points"); print "$header"; open(INFILE,... (1 Reply)
Discussion started by: lucho_1
1 Replies

9. Shell Programming and Scripting

How To Sort Array of Hashes ??

Some one plz help me how to sort an array of hashes ..... for e.g i have an array as @AoH = ( { ques => 10, marks => 32, }, { ques => 32, marks => 22, }, { ques => 2, marks => 41, }, ); now i want to sort this array with increasing value of "ques" ..... plz... (3 Replies)
Discussion started by: coolguyshail
3 Replies

10. Shell Programming and Scripting

perl: hashes, whiles, and last

hello everyone, i am creating 2 hashes from 2 different files, then looking for the value of one in the value of the other to make a new file. for example: file1: DENV => Denver file2: H224-0A-12 => DENVER if Denver is found in DENVER (case insensitive), a new hash now contains H224-0A-12... (0 Replies)
Discussion started by: effigy
0 Replies
Login or Register to Ask a Question