in reply to A Not so Simple Append

First of all your die is not very informative. That should be fixed.

Secondly what you need to do is walk through the file building up a data structure with your info, then walk through that and print. Something like this (untested) code:

open (PRV, "<$private") or die "Cannot read $private: $!"; my %connected; while (<PRV>) { chomp; my ($far, $dev) = (split(' ', lc($_)))[0,3]; push @{$connected{$far}}, $dev; } foreach my $dev (sort keys %connected) { my $fars = join ", ", @{$connected{$dev}}; print "$dev is connected to: $fars\n"; }

Replies are listed 'Best First'.
RE: Re (tilly) 1: A Not so Simple Append
by Limo (Scribe) on Oct 03, 2000 at 01:32 UTC
    Thanks much! It's actually doing the opposite of what I need, but if I stare at it long enough, I can learn what the code is doing! BTW, I do have a more informative "die" statement, but I omitted it to make my post less wordy. Silly me.