On Thu, 13 Nov 2003 01:05:37 +0000, Trent Rigsbee wrote:
> for ($count = 1; $count <= 5; $count++) {
> print "$count\n";
> }
This is very C'ish. In Perl we tend to:
for ( 1..5 ) {
print $_ . "\n";
# sleep( 1 );
}
Uncomment the sleep() thing if you want Perl to sleep for 1 second for
each iteration. Try 'perldoc -f sleep' for more information on sleep().
> 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'm not sure what you really mean, but if you want to replace the previous
number with the new one, you need to send some backspaces (\b) to STDOUT;
my $from = 1;
my $to = 60;
my $prev = 0;
$| = 1; # We don't want to buffer the output
for ( $from .. $to ) {
print $_;
sleep( 1 );
print "\b" x length($prev);
$prev = $_;
}
If you really need your application to display some information on its
progress, you really should check out Term::ProgressBar on CPAN:
http://www.cpan.org/
> Also, any methods or ideas on how to approach creating code in general?
1. Learn Perl.
2. Try to do something.
3. If #2 fails, read any documentation you can find.
4. comp.lang.perl.misc
--
Tore Aursand <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]