You probably want to use a nested hash...

In the first set of loops, where you have:

$ID = $Fields[6]; push (@id, $ID);
change it to:
$ID = $Fields[6]; $id{$ID}{count}++; # keep track of unique ID counts
[Don't forget to declare my %id with your other variables. And use warnings; and use strict;]

Then later you have:

foreach $id(@id)
rework this for the hash as:
foreach my $id(keys %id)
When you find the transport, add it to the hash like this:
$id{$id}{transport} = $TRANSPORT;
You can print this out right here if you like:
printf "%-20s %5d %10s\n", $id, $id{$id}{count}, $id{$id}{transport};
[though you will want %-5d if you really need the numbers left justified in the field.]

Update: I don't know how you keep track of IDs in the transport section. There seems to be a typo at $Clec_id.

Also, the transport section is not efficient. You can probably construct it similar to this:

foreach $FTP_Lines(@FTP_Lines) { chomp $FTP_Lines; @FTP_fields = split (/\;/, $FTP_Lines); if ( defined($id{$FTP_fields[0]} ) { $TRANSPORT = $FTP_fields[7]; $id{$id}{transport} = $TRANSPORT; printf "%-20s %5d %10s\n", $id, $id{$id}{count}, $id{$id}{transport}; } }
-QM
--
Quantum Mechanics: The dreams stuff is made of

In reply to Re: Help on displaying the output of two arrays by QM
in thread Help on displaying the output of two arrays by Anonymous Monk

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.