Hash of array printing issue.

Discussion in 'Perl' started by tanghz, Jul 20, 2009.

  1. tanghz

    tanghz

    Joined:
    Jul 20, 2009
    Messages:
    1
    Likes Received:
    0
    This is the data:
    CHR08FS019528015 . . 19528015 19528064 5.00E-20 . . 8
    CHR08FS019528015 . . 19528091 19528140 5.00E-20 . . 8
    CHR08FS019528217 . . 19528217 19528266 5.00E-20 . . 8
    CHR08FS019528217 . . 19528273 19528322 5.00E-20 . . 8

    I want to use hash of array to merge the first two lines and the last two lines with the scripts below:



    while (<>){
    chomp;
    @t=split /\t/;
    push (@{ $Objs{$t[0]} }, $t[1], $t[2], $t[3], $t[4], $t[5], $t[6], $t[7], $t[8]) ;
    }

    for $Obj (keys %Objs ){
    print "$Obj\t";
    print join("\t", @{ $Objs{$Obj}});
    print "\n";



    It should be like this
    CHR08FS019528015 . . 19528015 19528064 5.00E-20 . . 8 . . 19528091 19528140 5.00E-20 . . 8
    CHR08FS019528217 . . 19528217 19528266 5.00E-20 . . 8 . . 19528273 19528322 5.00E-20 . . 8


    but the real output is this:

    CHR08FS0.9528217. 19528273. 19528322 5.00E-20 ..00E-20. 8 . 8
    CHR08FS0.9528015. 19528091. 19528140 5.00E-20 ..00E-20. 8 . 8


    I checked all the hash array element has the correct data, just the output is incorrect, it seems the second part of the data overlapped with the first part, how come??? Who can help???

    thanks
     
    tanghz, Jul 20, 2009
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rp
    Replies:
    1
    Views:
    954
    red floyd
    Nov 10, 2011
  2. Anthony Martinez
    Replies:
    4
    Views:
    528
    Robert Klemme
    Jun 11, 2007
  3. Michal Suchanek
    Replies:
    6
    Views:
    565
    Nobuyoshi Nakada
    Jun 13, 2007
  4. Srijayanth Sridhar
    Replies:
    19
    Views:
    1,070
    David A. Black
    Jul 2, 2008
  5. Mothra
    Replies:
    16
    Views:
    388
    John W. Krahn
    Sep 12, 2003
  6. Tony N.

    Printing an array of hash refs

    Tony N., Sep 22, 2004, in forum: Perl Misc
    Replies:
    11
    Views:
    372
    Tony N.
    Sep 24, 2004
  7. Deepu

    Printing Hash of Array of Arrays

    Deepu, Jun 28, 2006, in forum: Perl Misc
    Replies:
    5
    Views:
    274
    Ted Zlatanov
    Jun 28, 2006
  8. Mike
    Replies:
    9
    Views:
    232
    J. Gleixner
    Oct 31, 2006
Loading...