in reply to Help on displaying the output of two arrays
In the first set of loops, where you have:
change it to:$ID = $Fields[6]; push (@id, $ID);
[Don't forget to declare my %id with your other variables. And use warnings; and use strict;]$ID = $Fields[6]; $id{$ID}{count}++; # keep track of unique ID counts
Then later you have:
rework this for the hash as:foreach $id(@id)
When you find the transport, add it to the hash like this:foreach my $id(keys %id)
You can print this out right here if you like:$id{$id}{transport} = $TRANSPORT;
[though you will want %-5d if you really need the numbers left justified in the field.]printf "%-20s %5d %10s\n", $id, $id{$id}{count}, $id{$id}{transport};
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:
-QMforeach $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}; } }
|
|---|
| 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 | |
by QM (Parson) on Oct 29, 2003 at 23:52 UTC |