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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.