in reply to Complex Data Structure

Here's (the beginning of) your problem:

foreach my $probeset_id (sort keys %{$row{$origin{$pip}}}){

In the above, you're saying "return the value for key $pip from hash %origin; use that value as a key in hash %row" and so on. Notice the "%origin" in this description? You don't have one. Instead, you have a scalar called $origin - and what you actually mean is

foreach my $probeset_id (sort keys %{$row{$origin}{$pip}}){

...and so on. The other error you have - a minor one, in comparison to the above - is that you've dug down one level too deep in your last 'foreach' statement:

foreach my $probeseq ( sort keys %{$row{$origin}{$pip}{$probeset_id}{$ +affyscore}{$gc}}){

If you look back to where you construct that hash, you'll notice that $row{$origin}{$pip}{$probeset_id}{$affyscore}{$gc}} is actually a scalar - not a hash. Trying to extract keys from it, as you do in the above statement, is not likely to be productive. Simply print the value of this variable.

Last of all - this isn't a mistake, but it is likely to lead to one (a mistype):

@data=split (/\t/,$_); my $probeset_id = $data[0]; my $origin = $data[1]; my $probeseq = $data[2]; my $pip = $data[3]; my $gc = $data[4]; my $affyscore = $data[5];

This is unnecessary. Better to use a hash slice:

my ($probeset_id, $origin, $probeseq, $pip, $gc, $affyscore) = split / +\t/;

-- 
Human history becomes more and more a race between education and catastrophe. -- HG Wells

Replies are listed 'Best First'.
Re^2: Complex Data Structure
by GrandFather (Saint) on Sep 14, 2008 at 23:52 UTC
    my ($probeset_id, $origin, $probeseq, $pip, $gc, $affyscore) = split / +\t/;

    is a list assignment. A hash slice assignment looks like:

    @hash{qw(this that the other)} = qw{some value or another);

    Perl reduces RSI - it saves typing

      Err... trying to do too many things at once. I started by demonstrating a hash slice, realized that it wasn't the best solution, changed the code, and forgot to change the comments. Thanks for catching it!

      
      -- 
      Human history becomes more and more a race between education and catastrophe. -- HG Wells
      
Re^2: Complex Data Structure
by sesemin (Beadle) on Sep 15, 2008 at 00:58 UTC
    Hi OKO1, Thanks for prompt response. Please see my response to Grand Father. What I really meant to do. Pedro