in reply to Help on displaying the output of two arrays

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

Replies are listed 'Best First'.
Re: Re: Help on displaying the output of two arrays
by Anonymous Monk on Oct 29, 2003 at 22:10 UTC

    Hi QM,

    I did those changes as you told me .. but the output didn't come as wanted ..it was totally different, If you don't mind can u do the changes and paste me the script.. I might be changing something which i should not be.
    Thanks alot

    Edit BazB: removed code tags.

      ...can u do the changes and paste me the script...
      As I noted in my update, there are some things I can't track down in your original, such as what id has to do with transport.

      It would be better for you to paste the updates you've made, so we can better advise you.

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of