I am using the perl Text::csv perl module and IO::Scalar module to get csv data the data is as follows:

id ,name,sal,post,income,country ,address..$#number_of_columns 21,hhdh,23,lawyer,0,US,GA,XYZ...$#number_of_rows

22,shjhds,24,perl programmer,999999999999,US,TX,XYZ..$#number_of_rows """""..... "......

i cannot find how i can create a hash record so that i can do a search on "ANY" key from the id col which has multiple values associated(name,sal,post,income,country ,address..$#number_of_columns) so as to obtain all values from any single row of record based on key (id) ---------------------------------------------------------

my $url1="http://xyz.com"; my $content = LWP::Simple::get($url1); my $abc= new IO::Scalar \$content; my $csv = Text::CSV->new(); my $data; while(<$abc>){ if ($csv->parse($_)) { next if (/#(.*?)somedata/);#skip the first line my @columns = $csv->fields();#get the coulmns and the +corresponding row value which are stored in each index of array print "Server id: $columns[0]\n\t Server_Name: $column +s[7]\n";#index 0 stores 21,22 after skipping column names similarly i +ndex 2 stores 23,24 #my %ass=($columns[0],$columns[2])#prints 21=> +23|22=>24 #print "@col1";# <code>#following is changed code $server_id= $columns[6]; $server_info{$server_id}=\@columns; #print $server_info{"'someno'"}; $query = "007"; use Data::Dumper; $info = $server_info{ "$query" } ; print Dumper $info; } }
--------------------------------------------------------------- </code>

code is running fine now what i want to do is get name value pairs for example id |state 2146_oak=>state::GA:;US How do i find single data based on key from the entire hash now i am able to get values for entire row based on key i just want a single value from the entire hash based on the row key. Also suppose we have a value called state =state::GA:;US .I want to do search on the vale and if i find keyword GA in the value string i need to use the key 2146_oak and use it for some purpose .how do i do pattern matching on this. Thnx for the help i am a beginner:) soon will become a Perl monk yipee!!


In reply to hash of hash by luckysing

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.