#!/usr/bin/perl

#################
##### Author:	Sebastian Enger 
##### eMail:	sebastian.enger@gmail.com
##### Web:		http://www.sebastian-enger.com
##### Licence:	Its only mine!
#################

system("renice 20 $$");
system("clear");

# first do a to install needed modules: perl -MCPAN -e 'force install "WWW::Google::SiteMap"'

use WWW::Google::SiteMap::Ping;

open(RH,"<sitemapurls.txt");	# urls with sitemaps to ping
	while(<RH>){
		PingGoogleForSitemap("$_");
	};
close RH;


sub PingGoogleForSitemap(){

	my $SiteMapUrl = shift;	

	my $ping = WWW::Google::SiteMap::Ping->new(
		"$SiteMapUrl",
	);

	$ping->submit;
	# print "\tThese pings succeeded:\n";
	foreach($ping->success) {
		print "\tSUCESS: $_ " if ( $_ =~ /\w/ );
	}

	# print "\tThese pings failed:\n";
	foreach($ping->failure) {
		print "\t\tFAILURE $_ " if ( $_ =~ /\w/ );
	}

	my $yahoo		= get("http://www.yahoo.com/ping?sitemap=$SiteMapUrl");
	my $msn			= get("http://search.msn.com/ping?sitemap=$SiteMapUrl");
	my $msn1		= get("http://search.live.com/ping?sitemap=$SiteMapUrl");
	my $yahoo1		= get("https://siteexplorer.search.yahoo.com/submit/ping?sitemap=$SiteMapUrl");

	return 1;

}; # sub PingGoogleForSitemap

