You could try reading from STDIN and either quit on a Ctrl-Z or some other
character

Ex:

#this reads in what you type and prints it
#entering ctrl-Z is seen as a blank line and quits

while (<STDIN>) {
        print;
}


\\Greg

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Su,
Yu (Eugene)
Sent: Thursday, October 06, 2005 3:08 PM
To: [email protected]
Subject: RE: how to interact with an endless loop

Hi All,

I want to write a simple perl script to start an endless loop (for reading
data from a periphery device, such as a measurement unit), but I also want
to be able to stop it anytime. Right now I use "Ctrl-Alt-Del" to do it.
There must be a better way. I has been trying to use open, pipe...not seem
to understand how to use them.

##### uncompleted code snippet #####

use strict;
use warnings;
use Tk;
use IO::Handle;

sub msgbox {
        my $msg=shift;
        my $mw = MainWindow->new;
        $mw->title("Attention!");
        $mw->Label(-text => $msg,
                        -width => 50,
                        -height => 8,
                        -font => "Arial 24 normal") -> pack;
        $mw->Button(-text => "OK", -font => "Arial 18 normal", -command =>
sub {$mw->destroy})->pack;
        $mw->focusForce;
        MainLoop;
        return 1;
}

# pop up a message widget and start a endless do loop at the same time. 
# msgbox("Press OK to stop the program."); # start a do loop, until the OK
button is pressed # do # {
#       print "\nreading...";
#       #read_temperature_sensor();
#       sleep(1);
#
# }until (OK button is pressed?)

Any idea how to do it? 

Thanks for help.

-Eugene
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to