learn_perl_se has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my $str = "Hello!"; chomp($str); foreach (split // ,$str) { print $_,"\n"; sleep 1; }
gives this output with sleep one second for every character!:
H e l l o !
What I would like is about the same code, but with this output instead:
This includes sleep one second between every character as in first code example above. This works fine, but the thing is; is it possible to get the output one character for every second and all on the same line? I have tried with /t instead of newline but that just gives meH e l l o !
in a bunch when code exits. So to be absolutely clear. I want output like this all on the same line:H e l l o
h (sleep) e (sleep) l (sleep) l (sleep) o (sleep) !(sleep)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: split sleep question
by zwon (Abbot) on May 01, 2009 at 13:19 UTC | |
|
Re: split sleep question
by gwadej (Chaplain) on May 01, 2009 at 13:19 UTC | |
|
Re: split sleep question
by marto (Cardinal) on May 01, 2009 at 13:28 UTC | |
by learn_perl_se (Initiate) on May 01, 2009 at 16:19 UTC |