Re: counter program by using closure
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 = <| 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 -- Those people who think they know everything are a great annoyance to those of us who do.-- Isaac Asimov -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: counter program by using closure
Chas. Owens wrote: On Sat, Dec 13, 2008 at 21:13, 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 = <(); } The problem is that my $counting = <(); select undef, undef, undef, .25; } WOW.. thank you and I will study this code now... this is great!! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: counter program by using closure
On Sat, Dec 13, 2008 at 21:13, 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 = < > | Counting... >| > | ++$count; >| > | >| > > EOF > > return sub { print $counting } > } > > my $real_count; > my $yeah = counter(); > while ($real_count < '35') { > ++$real_count; > system('clear'); > $yeah->(); > } The problem is that my $counting = <(); select undef, undef, undef, .25; } -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: counter program by using closure
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 = <| Counting... | | ++$count; | | | EOF return sub { print $counting } } my $real_count; my $yeah = counter(); while ($real_count < '35') { ++$real_count; system('clear'); $yeah->(); } I am assuming this will not work because above clousure will have no access to variable $count.. trying to see if there is another way to get this done. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
counter program by using closure
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 = <| Counting... | | ++$count; | | | EOF return sub { print $counting } } my $real_count; my $yeah = counter(); while ($real_count < '35') { ++$real_count; system('clear'); $yeah->(); } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/