Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

eibwen's scratchpad

by eibwen (Friar)
on May 10, 2005 at 16:58 UTC ( #455663=scratchpad: print w/replies, xml ) Need Help??

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`;

Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2021-09-23 15:35 GMT
Find Nodes?
    Voting Booth?

    No recent polls found