You might want to try the following call your script twice with the start
argument, then look at the processes running (just send the output of the
script to /dev/null or something like that for ease of use)

You will see the script running twice, this is because you started the Perl
interpreter twice. If you want to be able to do this you will have to look
into something called signaling. With this you can send your script a signal
to stop, this signal you can then process in anyway you like.

I hope this will help yo a bit, regards,

Rob



On 10/23/07, monk <[EMAIL PROTECTED]> wrote:
>
> I'm having problems accessing a variable outside its subroutine.
> I've tried several combinations too long to write here. Maybe I just
> can't see the forest for the trees.  But I'm lost.  I need your
> wisdom.
>
> I'd like my program below to change $status to zero to exit the loop.
>
> meaning...$> perl test.pl --start
> it prints out indefinitely "hello world"
>
> But if  $> perl test.pl --stop
> it gets out of the loop exiting the program.
>
>
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> <snip>
>
> our $status;
>
> sub start{
>    $status = 1;
>    while ($status == 1){
>                  print "hello world!\n";
>    }
> print "out of loop. Will exit now";
> exit;
> }
>
>
> sub stop {
>     $status = 0;
>
> }
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

Reply via email to