Skip to content

Instantly share code, notes, and snippets.

@dolmen
Created July 20, 2011 09:58
Show Gist options
  • Save dolmen/1094704 to your computer and use it in GitHub Desktop.
Save dolmen/1094704 to your computer and use it in GitHub Desktop.
Apple Store check, using AnyEvent
#!/usr/bin/perl
# AnyEvent version of https://gist.github.com/1094658
use 5.010;
use strict;
use warnings;
use AnyEvent;
use AnyEvent::HTTP;
my $w;
$w = AE::timer 0, 10, sub {
http_head "http://store.apple.com", sub {
my ($data, $headers) = @_;
if ($headers->{Status} == 404) {
say "Apple Store is down!"
} else {
say "Apple Store back up!"
}
};
};
my $cv = AE::cv;
my $brk = AE::signal 'INT', sub { $cv->send };
$cv->recv;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment