I run a lot of "setup" scripts. I made them to speed installs of software.
Now other people are using them. Several times
in the scripts users need to edit a file or some other
activity that will change the way in which the user might expect the script to run.
S/he needs to realize this _before_ the the event starts.
Hence a snippet!


Takes one arg requried, the time to countdown.
One arg possibe, a description of what's comming.
kinda looks like this with the number changing each second:
5 seconds until event
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"); }

In reply to Time until event by halxd2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.