Click here to get back home

catch_int\catch_hup subroutine

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
catch_int\catch_hup subroutine DJ 02-25-2005
Posted by DJ on February 25, 2005, 8:51 am
Please log in for more thread options


Has anyone ever used a routine to process signals in a Perl module?

In one of my Perl scripts I have two subroutines defined:

sub catch_hup
sub catch_int

In the main body of my code, I set them up as follows:

$SIG = &catch_hup;
$SIG = &catch_int;

This is all defined in the same script file. I would like to move the
subroutine definitions to a Perl module so that I can reuse these
definitions in different Perl scripts. So when I add the two
subroutines (catch_hup and catch_int) into my Module.pm file, I would
like to call them as follows:

$SIG = Module->catch_hup;
$SIG = Module->catch_int;

Is that even possible with Perl? The code that works was inherited and
I have a basic understanding of how it works. Currently I have other
subroutines defined in my Perl module that work fine. However, I'm
sure with signals, it doesn't work the same.

Any help would be appreciated!

Perl rookie!
DJ



Posted by Brian McCauley on February 25, 2005, 7:37 pm
Please log in for more thread options




DJ wrote:
>
> $SIG = &catch_hup;
> $SIG = &catch_int;
>
> This is all defined in the same script file. I would like to move the
> subroutine definitions to a Perl module so that I can reuse these
> definitions in different Perl scripts. So when I add the two
> subroutines (catch_hup and catch_int) into my Module.pm file, I would
> like to call them as follows:
>
> $SIG = Module->catch_hup;
> $SIG = Module->catch_int;

No, do the same thing you did in the first case:

$SIG = &Module::catch_hup;
$SIG = &Module::catch_int;

Or, of couse, you could have Module export them (using Exporter).

> Is that even possible with Perl? The code that works was inherited and
> I have a basic understanding of how it works. Currently I have other
> subroutines defined in my Perl module that work fine. However, I'm
> sure with signals, it doesn't work the same.

No there is no difference, if you had said...

$SIG = catch_hup;
$SIG = catch_int;

....it would not have worked either.



Posted by DJ on February 25, 2005, 2:03 pm
Please log in for more thread options


Thanks Brian! I'll give it a shot.

DJ



Posted by DJ on March 1, 2005, 7:39 am
Please log in for more thread options


It worked! The help is much appreciated!

DJ



Similar ThreadsPosted
"Undefined subroutine" November 21, 2004, 8:48 pm
referencing a param and $self in an OO subroutine March 20, 2007, 11:03 am
Options for passing Hash to a subroutine. March 30, 2005, 7:39 pm
Perl Tk:Scheduler command called subroutine fails to talk to tk widgets January 31, 2007, 2:05 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap