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