#!/usr/bin/env perl use strict; use warnings; use 5.010; use File::ShareDir qw(dist_file); use Getopt::Long; use IO::Handle; use IPC::Run qw(harness); use SDL::Mixer; use SDL::Music; use Term::Size; use Time::HiRes qw(usleep); our $VERSION = '0.0'; my $beep = 0; my $id = 0; my $rtt = 0; my $last_id = 0; my $dead_count = 0; my $column = 0; my $column_max = Term::Size::chars; my $beep_file = dist_file( 'ekgping', 'beep.ogg' ); my $quiet = 0; GetOptions( 'f|beep-file=s' => \$beep_file, 'q|quiet' => \$quiet, 'V|version' => sub { say "ekgping version ${VERSION}"; exit 0 }, ) or usage(); my $host = shift or usage(); my @ping_opts = @ARGV; my $mixer = SDL::Mixer->new(); my $beep_sound = SDL::Music->new($beep_file); my $ping = harness( [ 'ping', '-n', @ping_opts, $host ], '<' => \undef, '>&' => \&parse_ping_output, ); local $SIG{INT} = \&quit; local $SIG{TERM} = \&quit; local $SIG{QUIT} = \&quit; sub parse_ping_output { my ($line) = @_; chomp($line); if ( $line =~ m{ ^ \d+ \s bytes \s from \s \S+ \s icmp_req = (? \d+ ) \s ttl = (? \d+ ) \s time = (?