You might want to look into fork
http://perldoc.perl.org/functions/fork.html
http://www.tutorialspoint.com/perl/perl_fork.htm


On Mon, Dec 15, 2008 at 3:40 PM, Richard <rich.j...@gmail.com> wrote:
> John W. Krahn wrote:
>>
>> Richard wrote:
>>>
>>> John W. Krahn wrote:
>>>>
>>>> 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->();
>>>>    }
>>>
>>> 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?
>>
>> $counting contains the format string for printf() and the first argument
>> $clear is substituted for '%s' in $counting and the second argument ++$count
>> is substituted for '%2d' in $counting.  They are substituted in the same
>> order as they appear.
>>
>>
>>
>>
>> John
>
> Just curious, in programming in general, is it possible to do other things
> while counting is going on?
> Is this possible in perl?
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>



-- 
David Schmidt   |   http://www.fm5.at

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to