in reply to Re^2: simple question about printing vars
in thread simple question about printing vars

Maybe like this?
#!/usr/bin/perl use strict; use warnings; open PO, "netstat -na|" or die "Can't pipe open: $!\n"; my %count; while (<PO>) { next unless /^udp/ or /^tcp/; my @fields = split; # split $_ on whitespace $count{$fields[3]}++; ## next jumps here } close PO; for my $ip (sort keys %count) { print "\t$count{$ip} $ip\n"; }

Have a nice day, j

Replies are listed 'Best First'.
Re^4: simple question about printing vars
by httpd (Novice) on Nov 03, 2011 at 16:02 UTC
    I will try that, thanks ;)