forcing immediate output of a subroutine
- From: mlaw75@xxxxxxxxx
- Date: 28 Feb 2007 08:09:28 -0800
I wanted to do something fancy for the user when they run my script
from the command line. Basically, I wrote this subroutine so that it
would output what would appear to be a spinning cursor while the
script was running.
##start of Fancy subroutine
sub Fancy
{
$FlashIndex = shift;
++$FlashIndex;
if ($FlashIndex == 1) { $StatusLine = " \\"; }
elsif ($FlashIndex == 2) { $StatusLine = " \|"; }
elsif ($FlashIndex == 3) { $StatusLine = " \/"; }
else { $StatusLine = " \-"; $FlashIndex = 0;}
$StatusLen = length($StatusLine);
print "$StatusLine";
print "\b" x $StatusLen;
}
##end of Fancy subroutine
$FlashIndex and $StatusLine are scoped globally, and each time the
function is called, $FlashIndex is passed to the function. The output
should be what appears to be a spinning cursor made up of \,|,/, and
-.
The problem is that the print statement executes at the end of the
script, not during, so I don't get a spinning cursor until the end of
the program. Is this because I am executing it in a subroutine? Is
there something about subroutines that prevents output from being
generated until program termination?
Thanks in advance.
.
- Follow-Ups:
- Re: forcing immediate output of a subroutine
- From: Paul Lalli
- Re: forcing immediate output of a subroutine
- Prev by Date: Re: Characters from encryption
- Next by Date: Re: Characters from encryption
- Previous by thread: Characters from encryption
- Next by thread: Re: forcing immediate output of a subroutine
- Index(es):
Relevant Pages
|
|