> -------- Original Message --------
> Subject: Calling subroutine every second using alarm fails
> From: Kelly Jones <kelly.terry.jo...@gmail.com>
> Date: Wed, April 01, 2009 5:48 am
> To: beginners@perl.org
> 
> 
> I want a script that constantly accepts user input, but runs a
> subroutine every second to do other work.


what I thought is to fork a child to do the stuff.

my $child = fork;
die "cant fork $!" unless defined $child;

if ($child) {  # in parent
    while(<>) {
        # do something
    }
} else {  # in child
    while( some_condition ) {
       # do stuff
       sleep 1;
    }
    exit 0;
}


regards,
Jeff.


--
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