In this case, sub report_stats would only be called when
the script gets a sigint.
Be sure to read perlipc and pay attention to the warnings
therein.
I don't think this will work under Windows, but I'm pretty
sure that Term::ReadKey will.
Thomas Jakub wrote:
>
> signal handling sounds interesting! I'll have to play
> around with that tommorow, along with Readkey! For
> signal handling, will it only go to the report_stats
> function if you kill it in some fashion, or will it go
> there when the program automatically ends? If it
> doesn't, I can just make the end of the prgm, and the
> signal handler both call the same function, or
> whatever... Well, thanks! This looks really
> promising!
>
> --- Will Cottay <[EMAIL PROTECTED]> wrote:
> > You might want to look at the CPAN module
> > Term::ReadKey. It provides
> > for
> > non-blocking reads.
> >
> > Or, you could install a signal handler ie:
> >
> > $SIG{INT} = \&report_stats;
> >
> > while (1) {
> > ... your website checking code here ...
> > }
> >
> > sub report_stats {
> > $SIG{QUIT} = \&report_stats;
> > ...Your stat reporting and exit code here
> > }
> >
> > and hit ^C when you want it to report and stop.
>