Lets say you have a perl script sucking rows out of a database. You generally want to know that it's still running, instead of it sitting there, working it's butt off, and not printing anything while it performs some math or hashing or something. This whirleygig prints a character to stdout or stderr so you can see it working.
#!/usr/bin/perl
$|=1;$WHIRLEY_COUNT=-1;
#$whirley='-\|/';@whirley=split //,$whirley;
#$whirley='.o0O0o';@whirley=split //,$whirley;
#$whirley='1234567890';@whirley=split //,$whirley;
#$whirley='';@whirley=split //,$whirley;
$whirley=" ".pack(C,176).pack(C,177).pack(C,178).pack(C,219).pack(C,17
+8).pack(C,177). pack(C,176);@whirley=split //,$whirley;
sub whirley {
if ($WHIRLEY_COUNT+1==@whirley) {
$WHIRLEY_COUNT=0;
} else {
$WHIRLEY_COUNT++;
}
return "@whirley[$WHIRLEY_COUNT]";
}
while (1) {
sleep 1;
print STDERR "please wait : ".&whirley."\r";
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|