Please wait... [was: Perl - Blinking Text]

Message thread · created 2000-08-24 · last edited 2026-11-22 · Item Language: English
Topics: ASCII art
Source: asciiart.eu

August 2000, cross-posted from comp.lang.perl.misc: Perl one-liners that animate a ‘Please wait’ message with carriage returns and sleep. Animation with \r survives in programmers’ jokes.

Quoted in the article:

  • c7-perl-wait: Ilmari Karonen, 2000-08-24 (post)
  • c7-perl-code: Ilmari Karonen, 2000-08-24 (post)

alt.ascii-art.animation, comp.lang.perl.misc · 7 posts · 2000-08-24 – 2000-08-25

Ilmari Karonen <ilt...@sci.invalid> ·
↳ a post not in this thread · asciiart.eu · c7-perl-wait · c7-perl-code · ↑ tree
In article <spi...@corp.supernews.com>, Greg Bacon wrote:
>In article <200...@ng-ch1.aol.com>,
>    Louis <lou...@aol.com> wrote:
>: Hi.  While my perl script is processing, I would like the print line
>: "Please wait, processing data .. " to blink at the command line
>: (UNIX).  Does anyone know how I can get the text to blink?
>
>Yuck.  Just say no.  How about a spinner?

Twirling batons are rather cliche, though.  If you're going to have
your users staring at a "please wait" message, the least you could do
is make it a little bit interesting.

  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
	   => pack "v" => $i while ++$i and sleep 1'

  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
	   => pack "v" => $i^$i/2 while ++$i and sleep 1'

Here are two I came up with right now - I can't decide which one I
like more.  All it takes is a bit of creativity.

[Crossposted from comp.lang.perl.misc to alt.ascii-art.animation.]

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla  | "By promoting postconditions to
and its pseudonyms -    |  preconditions, algorithms become
do not feed the troll.  |  remarkably simple."  -- Abigail

Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fd588,7ad72948312cb279,start
X-Google-Attributes: gidfd588,public
X-Google-Thread: fa0ae,85d37e30d034d7ec
X-Google-Attributes: gidfa0ae,public
From: Ilmari Karonen <ilt...@sci.invalid>
Subject: Please wait... [was: Perl - Blinking Text]
Date: 2000/08/24
Message-ID: <967...@itz.pp.sci.fi>#1/1
X-Deja-AN: 661921426
References: <200...@ng-ch1.aol.com> <spi...@corp.supernews.com>
X-Complaints-To: new...@saunalahti.fi
X-Trace: tron.sci.fi 967118400 1901 195.74.0.20 (24 Aug 2000 12:00:00 GMT)
Organization: (dis)Order of the Holy Spoon (or whatever)
User-Agent: postit.pl 0.05
Reply-To: Ilmari Karonen <use...@itz.pp.sci.fi>
NNTP-Posting-Date: 24 Aug 2000 12:00:00 GMT
Newsgroups: comp.lang.perl.misc,alt.ascii-art.animation

↑ tree

Gwyn Judd <tjl...@guvfybir.qlaqaf.bet> ·
I was shocked! How could Ilmari Karonen <ilt...@sci.invalid>
say such a terrible thing:

>Twirling batons are rather cliche, though.  If you're going to have
>your users staring at a "please wait" message, the least you could do
>is make it a little bit interesting.
>
>  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
>	   => pack "v" => $i while ++$i and sleep 1'
>
>  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
>	   => pack "v" => $i^$i/2 while ++$i and sleep 1'

rand $i makes a nice effect too :)

-- 
Gwyn Judd (print `echo 'tjl...@guvfybir.qlaqaf.bet' | rot13`)
Boob's Law:
	You always find something in the last place you look.

Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fd588,7ad72948312cb279
X-Google-Attributes: gidfd588,public
X-Google-Thread: fa0ae,85d37e30d034d7ec
X-Google-Attributes: gidfa0ae,public
From: tjl...@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Please wait... [was: Perl - Blinking Text]
Date: 2000/08/24
Message-ID: <slr...@thislove.dyndns.org>#1/1
X-Deja-AN: 661956653
References: <200...@ng-ch1.aol.com> <spi...@corp.supernews.com> <967...@itz.pp.sci.fi>
X-Complaints-To: new...@xtra.co.nz
X-Trace: news.xtra.co.nz 967125475 210.55.45.80 (Fri, 25 Aug 2000 01:57:55 NZST)
Organization: World Center for Flux Capacitor Research
User-Agent: slrn/0.9.6.2 (Linux)
NNTP-Posting-Date: Fri, 25 Aug 2000 01:57:55 NZST
Newsgroups: comp.lang.perl.misc,alt.ascii-art.animation

↑ tree

Ilmari Karonen <ilt...@sci.invalid> ·
In article <slr...@thislove.dyndns.org>, Gwyn Judd wrote:
>I was shocked! How could Ilmari Karonen <ilt...@sci.invalid>
>say such a terrible thing:
>>
>>  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
>>	   => pack "v" => $i while ++$i and sleep 1'
>>
>>  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
>>	   => pack "v" => $i^$i/2 while ++$i and sleep 1'
>
>rand $i makes a nice effect too :)

A bit too, well, random for my taste.  $i^$i/4 looks somewhat less
repetitive than the above two, yet sufficiently ordered that one could
probably stare at it quite some time trying to figure out the pattern.

Another somewhat simpler looking animation I came up with is:

  perl -e '$i=$|=1; print "\rPlease wait", grep tr/01/ ./ =>
           unpack "b*" => pack "V" => $i^=$i<<1 while sleep 1'

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"True, but the user receiving the e-mailed password might think
 'Strange, I don't remember choosing "&\xe7?\x9b\x3f\t\xef\xb7"
 as my password, and how do I type it?'"  -- Keith C. Ivey

Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fd588,7ad72948312cb279
X-Google-Attributes: gidfd588,public
X-Google-Thread: fa0ae,85d37e30d034d7ec
X-Google-Attributes: gidfa0ae,public
From: Ilmari Karonen <ilt...@sci.invalid>
Subject: Re: Please wait... [was: Perl - Blinking Text]
Date: 2000/08/24
Message-ID: <967...@itz.pp.sci.fi>#1/1
X-Deja-AN: 662101853
References: <200...@ng-ch1.aol.com> <spi...@corp.supernews.com> <967...@itz.pp.sci.fi> <slr...@thislove.dyndns.org>
X-Complaints-To: new...@saunalahti.fi
X-Trace: tron.sci.fi 967149856 15866 195.74.0.20 (24 Aug 2000 20:44:16 GMT)
Organization: (dis)Order of the Holy Spoon (or whatever)
User-Agent: postit.pl 0.05
Reply-To: Ilmari Karonen <use...@itz.pp.sci.fi>
NNTP-Posting-Date: 24 Aug 2000 20:44:16 GMT
Newsgroups: comp.lang.perl.misc,alt.ascii-art.animation

↑ tree

David Riley <dav...@dmriley.demon.co.uk> ·
Ilmari Karonen <ilt...@sci.invalid> writes:

> Another somewhat simpler looking animation I came up with is:
> 
>   perl -e '$i=$|=1; print "\rPlease wait", grep tr/01/ ./ =>
>            unpack "b*" => pack "V" => $i^=$i<<1 while sleep 1'

I like this one best so far. It also looks good using Abigail's
prime number regexp:

perl -e '$i=$|=1; while ($i++) {print "\rPlease wait", grep tr/01/ ./ =>
unpack "b*" => pack "V" => $i if (1 x $i) !~ /^(11+)\1+$/ and sleep 1;'}

-- 
David Riley 		dav...@dmriley.demon.co.uk

Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fd588,7ad72948312cb279
X-Google-Attributes: gidfd588,public
X-Google-Thread: fa0ae,85d37e30d034d7ec
X-Google-Attributes: gidfa0ae,public
From: David Riley <dav...@dmriley.demon.co.uk>
Subject: Re: Please wait... [was: Perl - Blinking Text]
Date: 2000/08/25
Message-ID: <m3r...@dmriley.demon.co.uk>#1/1
X-Deja-AN: 662281587
X-NNTP-Posting-Host: dmriley.demon.co.uk:194.222.183.234
References: <200...@ng-ch1.aol.com> <spi...@corp.supernews.com> <967...@itz.pp.sci.fi> <slr...@thislove.dyndns.org> <967...@itz.pp.sci.fi>
X-Complaints-To: abu...@demon.net
X-Trace: news.demon.co.uk 967192775 nnrp-01:11657 NO-IDENT dmriley.demon.co.uk:194.222.183.234
Organization: None
NNTP-Posting-Date: 25 Aug 2000 08:38:34 GMT
Newsgroups: comp.lang.perl.misc,alt.ascii-art.animation

↑ tree

Greg Bacon <gba...@HiWAAY.net> ·
In article <967...@itz.pp.sci.fi>,
    Ilmari Karonen  <use...@itz.pp.sci.fi> wrote:

: Twirling batons are rather cliche, though.  If you're going to have
: your users staring at a "please wait" message, the least you could do
: is make it a little bit interesting.

How about this?

    sub bubbles {
        my @bubble = (' ', '.', 'o', 'O');
        my $len = 10;
        my $tank = join '',
                   map $bubble[rand @bubble],
                   1 .. $len;

        my $tmp;
        while (1) {
            print "\rPlease wait $tank";

            $tank =~ s/(OO+)/$tmp = ' ' x length $1;
                             substr($tmp, rand length $1, 1) = 'O';
                             $tmp/eg;

            $tank =~ s/oo/     rand() < 0.5 ? 'O ' : ' O'/eg;
            $tank =~ s/\.\./   rand() < 0.5 ? 'o ' : ' o'/eg;
            $tank =~ s/Oo/     rand() < 0.5 ? 'O ' : ' O'/egi;
            $tank =~ s/\.o|o\./rand() < 0.5 ? 'o ' : ' o'/eg;
            $tank =~ s/\.O|O\./rand() < 0.5 ? 'oO' : 'Oo'/eg;

            while (rand() < 0.6) {
                substr($tank, rand $len, 1) = $bubble[rand @bubble];
            }

            select undef, undef, undef, 0.2;
        }
    }

Greg
-- 
Windows was created to keep the stoopid people away from Unix, you know.
An "MS advocate" is already beneath contempt.
    -- Tom Christiansen

Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fd588,7ad72948312cb279
X-Google-Attributes: gidfd588,public
X-Google-Thread: fa0ae,85d37e30d034d7ec
X-Google-Attributes: gidfa0ae,public
From: gba...@HiWAAY.net (Greg Bacon)
Subject: Re: Please wait... [was: Perl - Blinking Text]
Date: 2000/08/24
Message-ID: <sqa...@corp.supernews.com>#1/1
X-Deja-AN: 661976215
References: <200...@ng-ch1.aol.com> <spi...@corp.supernews.com> <967...@itz.pp.sci.fi>
X-Complaints-To: new...@supernews.com
X-Eric-Conspiracy: There is no conspiracy.
Organization: Eric Conspiracy Secret Labs
Reply-To: Greg Bacon <gba...@hiwaay.net>
Newsgroups: comp.lang.perl.misc,alt.ascii-art.animation
Originator: gba...@HiWAAY.net (Greg Bacon)

↑ tree

Abigail <abi...@foad.org> ·
Greg Bacon (gba...@HiWAAY.net) wrote on MMDL September MCMXCIII in
<URL:news:sqa...@corp.supernews.com>:
@@ 
@@ How about this?
@@ 
@@     sub bubbles {
@@         my @bubble = (' ', '.', 'o', 'O');
@@         my $len = 10;
@@         my $tank = join '',
@@                    map $bubble[rand @bubble],
@@                    1 .. $len;
@@ 
@@         my $tmp;
@@         while (1) {
@@             print "\rPlease wait $tank";
@@ 
@@             $tank =~ s/(OO+)/$tmp = ' ' x length $1;
@@                              substr($tmp, rand length $1, 1) = 'O';
@@                              $tmp/eg;
@@ 
@@             $tank =~ s/oo/     rand() < 0.5 ? 'O ' : ' O'/eg;
@@             $tank =~ s/\.\./   rand() < 0.5 ? 'o ' : ' o'/eg;
@@             $tank =~ s/Oo/     rand() < 0.5 ? 'O ' : ' O'/egi;
@@             $tank =~ s/\.o|o\./rand() < 0.5 ? 'o ' : ' o'/eg;
@@             $tank =~ s/\.O|O\./rand() < 0.5 ? 'oO' : 'Oo'/eg;
@@ 
@@             while (rand() < 0.6) {
@@                 substr($tank, rand $len, 1) = $bubble[rand @bubble];
@@             }
@@ 
@@             select undef, undef, undef, 0.2;
@@         }
@@     }


That seems to need a $| = 1.



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-

Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fa0ae,85d37e30d034d7ec
X-Google-Attributes: gidfa0ae,public
X-Google-Thread: fd588,7ad72948312cb279
X-Google-Attributes: gidfd588,public
From: abi...@foad.org (Abigail)
Subject: Re: Please wait... [was: Perl - Blinking Text]
Date: 2000/08/24
Message-ID: <slr...@alexandra.foad.org>#1/1
X-Deja-AN: 662092324
References: <200...@ng-ch1.aol.com> <spi...@corp.supernews.com> <967...@itz.pp.sci.fi> <sqa...@corp.supernews.com>
X-Date: MMDL September MCMXCIII
X-HTTP: http://purl.oclc.org/NET/Abigail
X-Revision: $Revision: 1.2 $
Organization: Abigail's Kinderboerderijen
User-Agent: slrn/0.9.6.2 (Linux)
Reply-To: abi...@foad.org
Newsgroups: comp.lang.perl.misc,alt.ascii-art.animation

↑ tree

Greg Bacon <gba...@HiWAAY.net> ·
In article <slr...@alexandra.foad.org>,
    Abigail <abi...@foad.org> wrote:

: Greg Bacon (gba...@HiWAAY.net) wrote on MMDL September MCMXCIII in
: <URL:news:sqa...@corp.supernews.com>:
:
: @@ How about this?
: @@ 
: @@     sub bubbles {
: @@         [...]
: @@     }
: 
: That seems to need a $| = 1.

Yeah, and a call to bubbles() while we're at it.  I thought they were
understood. :-)

Greg
-- 
People should think first, then wave with awards.
    -- Abigail

Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fd588,7ad72948312cb279
X-Google-Attributes: gidfd588,public
X-Google-Thread: fa0ae,85d37e30d034d7ec
X-Google-Attributes: gidfa0ae,public
From: gba...@HiWAAY.net (Greg Bacon)
Subject: Re: Please wait... [was: Perl - Blinking Text]
Date: 2000/08/25
Message-ID: <sqd...@corp.supernews.com>#1/1
X-Deja-AN: 662392610
References: <200...@ng-ch1.aol.com> <967...@itz.pp.sci.fi> <sqa...@corp.supernews.com> <slr...@alexandra.foad.org>
X-Complaints-To: new...@supernews.com
X-Eric-Conspiracy: There is no conspiracy.
Organization: Eric Conspiracy Secret Labs
Reply-To: Greg Bacon <gba...@hiwaay.net>
Newsgroups: comp.lang.perl.misc,alt.ascii-art.animation
Originator: gba...@HiWAAY.net (Greg Bacon)

↑ tree

Source: asciiart.eu

The messages, and the works they contain, belong to their authors and are published here as an archive. If you are one of them and want a correction or a removal, write to me.

Available documentssizedownload
t2015f7b929.json (json)mail-usenet-thread 0.6archived copy, not distributed54K–

Browse the Archive →