John W. Krahn wrote:
Richard wrote:
wanted to draw a box that's counting up for certain time.
Thought I could use the counter but it just displays the box not the
number..
can anyone point it out for me?
thank you.
use warnings;
use strict;
sub counter {
my $count;
my $counting = <<EOF;
====================================================
|
Counting...
|
|
++$count;
|
|
|
====================================================
EOF
return sub { print $counting }
}
my $real_count;
my $yeah = counter();
while ($real_count < '35') {
++$real_count;
system('clear');
$yeah->();
}
You want something more like this:
sub counter {
my $count;
my $clear = `clear`;
my $counting = <<'EOF';
%s====================================================
| Counting... |
| %2d |
| |
====================================================
EOF
return sub { local $| = 1; printf $counting, $clear, ++$count }
}
my $yeah = counter();
for ( 1 .. 35 ) {
sleep 1;
$yeah->();
}
John
this is interesting and this also works well.
My question is, how does perl know in this instance that %2d is refering
to $count.. is it because $clear contains none numeric value or because
$count contains numeric value?
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/