On Wed, 2003-11-12 at 20:05, Trent Rigsbee wrote:
> I'm sure this is easy but I'm a newbie. I was doing control statements (for,
> while,etc.) like this:
>
> for ($count = 1; $count <= 5; $count++) {
> print "$count\n";
> }
>
> What I wanted to do was to make each number appear in sequence like you see
> in a countdown (or up, in this case) instead of all on the screen at once.
> I've tried using sleep but I'm not getting anywhere with it. Any ideas?
> Also, any methods or ideas on how to approach creating code in general? For
> example, what's the thought process for trying to do what I want to do? I've
> tried pseudo code and it's helped some but then I hit the wall and don't how
> to go further. Thanks!
>
Try this code....either of these might be what you're looking for
#!/usr/bin/perl
#
use warnings;
use strict;
print "printing 1thru5 with buffering\n";
select undef, undef, undef, 0.25 or print $_
for 1 .. 5;
print "\nflush forced\n";
$|++;
print "printing 1thru5 without buffering\n";
select undef, undef, undef, 0.25 or print $_
for 1 .. 5;
print "\nflush forced\n";
Hope this helps,
--
Kevin Old <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]