2008/8/11 Brian Raven <[EMAIL PROTECTED]>

> Tobias Hoellrich <> wrote:
> > Try:
> >     $|++;
> > to unbuffer STDOUT.
> >
> > Hope this helps - Tobias
>
> Not quite. <pedant_mode> That variable activates autoflush, which isn't
> quite the same as unbuffered output, on the currently selected
> filehandle, which may not actually be STDOUT (see 'perldoc perlvar').
> </pedant_mode>
>
> Also, it is usually better to localise the use of such special
> variables. For example:
>
> print "Doing stuff ";
> for (1..20) {
>    local $| = 1;
>    select undef, undef, undef, 0.5;
>    print ".";
> }
> print "\n";
>
> Also, consider a more 'sophisticated' alternative to ".", that I
> sometimes use.
>
> print "Doing some more stuff  ";
> my $i = 0;
> for (1..20) {
>    local $| = 1;
>    select undef, undef, undef, 0.5;
>    print "\b" . qw{| / - \\}[$i++ % 4]; } print "\b \n";
>
> HTH
>
> --
> Brian Raven
>
>
> Visit our website at http://www.nyse.com
>
>
Or consider an OO approach, without the sneaky 3 undefs:-

package Spinner;

sub new
{
    return bless { position => 0, picture => [ qw( | / - \ ) ] }, shift;
}

sub spin
{
    my $obj = shift;

    $obj->{position} = ( ++$obj->{position} ) % @{ $obj->{picture} };

    print "\b$obj->{picture}[ $obj->{position} ]";
}

DESTROY
{
    print "\b \n";
}


package main;

use Win32;

local $| = 1;

print "Doing even more stuff . . .  ";

my $spinner = new Spinner;

for ( 1 .. 26 )
{
    $spinner->spin();

    Win32::Sleep(50);
}




[OT]: Changed jobs then Brian?


Just in
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to