sub timetill($;$) { my $pipe = $|;#pipe value is saved $| = 1;#pipe value changed to flush the buffer my $time = shift || return -1;#how long my $line = shift || " seconds until event";#what chomp $time; chomp $line; my $backcount = length $line; $backcount+=7;#this is where you might need to edit #to suit you. Spaces, and number display is added #to the total count to backup while($time > 0) { print " " . ' ' x (3 - length($time)) . "$time $line"; foreach (1..$backcount){print "\b"} $time -= 1; sleep 1; } $| = $pipe;#yea maybe I don't need to replace $| #but I sleep better knowing I'd put #everyting back the way I found it. #I tend to use it like this: #timetill(10, 'edit /etc/inetd.conf'); #system("vi /etc/inetd.conf"); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Time until event
by blokhead (Monsignor) on Sep 19, 2002 at 15:44 UTC | |
by petral (Curate) on Sep 19, 2002 at 21:56 UTC | |
Re: Time until event
by Aristotle (Chancellor) on Sep 19, 2002 at 19:18 UTC |