Re: Script to update your PPM Repositories -- Testing for a ping reply on the various protocols supported by Net::Ping proved fairly simple; however I opted for minimalist output in the interest of clean and concise code (hence why I didn't post this particular update to the thread proper).
Adding repository status messages (eg "$repository is alive" or "$repository is unresponsive to $_ ping") is fairly trivial; however determining when a repository is unresponsive to all ping attempts (eg "dead") appears to complicate the code more than the presumed benefit.
use strict;
use warnings;
use PPM::Repositories;
use Net::Ping;
foreach my $repository (split(/[\r\n]/, `ppm rep`)) {
next unless $repository =~ s/^\[[\d\ ]+\]\ (.*)$/$1/;
system("ppm rep delete $repository > NUL") unless $repository =~ /
+activestate/i;
}
foreach my $repository (keys %Repositories) {
my $domain = my $location = $Repositories{$repository}->{location}
+;
next unless $domain =~ s|^\s*http://([^/]+)/.*$|$1|;
foreach (qw/tcp udp icmp stream syn external/) {
next unless Net::Ping->new($_)->ping($domain);
system("ppm repository add $repository $location > NUL");
last;
}
}
print $/, `ppm rep`;
|