ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-unix-users
perl-unix-users
[Perl-unix-users] perl Hash help
by Perdeep Mehta other posts by this author
Jan 23 2007 10:04AM messages near this date
[Perl-unix-users] PDF Paragraphs | Re: [Perl-unix-users] perl Hash help
Hi,

I am looking for help to retrieve from a Hash of Hashes in insertion
order? I am not an expert in multi-dimensional Hashes, how could I use
Tie::IxHash module with a sub-Hash, if I could?

Here is an example, I want to retrieve from sub-hash
%{$dir_contents-> {$item}  in the insertion order. I want to first print
key and value for "template_id", then "trace_name", then "trace_file",
and so on...

    foreach my $item (keys %$dir_contents ) {
       print "$item\n";
       foreach my $k (keys %{$dir_contents-> {$item}} ) {
           print "  $k =>  $dir_contents->{$item}{$k}\n";
       }
    }


Here is sub that I am using to build the HoH:

        my %trace_info = ();
        while( my $f = readdir( DIR )) {
            $count++;
            next if( $f eq '.' or $f eq '..' );
            my($template) = ($f =~ /(\d+[A-Z][A-Z]*)[0-9]*/);
            my($tracename) = ($f =~ /\d+([A-Z][A-Z]*[0-9]*)[a-z]/);
            ...
            ...
            $trace_info{$count}{'template_id'} = $template;
            $trace_info{$count}{'trace_name'} = $tracename;
            $trace_info{$count}{'trace_file'} = $tracefile;
            $trace_info{$count}{'trace_format'} = $traceformat;
            $trace_info{$count}{'trace_end'} = $tracedirection;
         }
      return \%trace_info;

Thanks,
perdeep

Perdeep Mehta
Hartwell Center for Bioinformatics & Biotechnology
St. Jude Children's Research Hospital
Memphis, TN 38105-2794
Tel: 901-495 3774
http://www.hatwellcenter.org/
Thread:
Perdeep Mehta
Bill Luebkert
Perdeep Mehta
Matt Schneider
Perdeep Mehta
Perdeep Mehta
Justin Devanandan Allegakoen
Andy Bach

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved