[26599] in Perl-Users-Digest
Perl-Users Digest, Issue: 8725 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 30 18:05:27 2005
Date: Wed, 30 Nov 2005 15:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 30 Nov 2005 Volume: 10 Number: 8725
Today's topics:
Re: ASTM checksum <cNaOlSePbA@MvPeLtEsAtSaEr.com>
How to tell if a method exists <brian.miller@alcatel.com>
Re: Killing all child processes upon parent exit xhoster@gmail.com
lookfor failure in SerialPort <cNaOlSePbA@MvPeLtEsAtSaEr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 30 Nov 2005 14:21:41 -0600
From: Spin <cNaOlSePbA@MvPeLtEsAtSaEr.com>
Subject: Re: ASTM checksum
Message-Id: <11os2ehl294g25f@corp.supernews.com>
Anno Siegel wrote:
> I didn't write what follows, I replied to it. Please watch the
> attributions.
>
> Anno
Right. I didn't get Jim's post in my news reader so I assumed it was you
(your post was next). Apologies,
Caleb
------------------------------
Date: Wed, 30 Nov 2005 13:59:59 -0500
From: Brian Miller <brian.miller@alcatel.com>
Subject: How to tell if a method exists
Message-Id: <438df6b0@news.alcatel.com>
Hello All,
I am attempting to find a way to see if a method exists within a
specific package. I cannot use the PACKAGE->can(method) because
it follows the class hierarchy and it is possible that the method
exists somewhere else. What I was hopping to do is to have a base class
that scans the class hierarchy of an object and executes (in a specific
order) a method (let's say post_init). This would eliminate the need
for each method to run through it's package @ISA array and execute the
parents version of the method. If anyone has a suggestion I would
greatly appreciate it.
Thanks
Brian Miller
brian.miller@alcatel.com
------------------------------
Date: 30 Nov 2005 20:08:00 GMT
From: xhoster@gmail.com
Subject: Re: Killing all child processes upon parent exit
Message-Id: <20051130150800.102$zw@newsreader.com>
bsder <snort_sam@yahoo.com> wrote:
> Hi,
>
> Could anyone please tell me how to kill all child processes when parent
> exit?
> elsif ($kidpid == 0) { # child
> my ($cPort, $cHost) = unpack_sockaddr_in($addr);
> my $cHostName = inet_ntoa($cHost);
> print STDOUT "Client host: $cHostName\n";
> print STDOUT "Client port: $cPort\n";
> print NEWSOCK "Welcome to Code Generator.\r\n";
>
> while (my $m=<NEWSOCK>) {
> $m =~ s/\n|\r//g;
> last if ($m eq ".");
> print NEWSOCK "Server received $m\r\n";
> }
> close(NEWSOCK) || die "close in child: $!";
> delete %kids->{$kidpid};
> exit;
What is the point of the delete? For one thing, you've never put
anything into %kids, neither in parent nor child, so there is nothing to
delete. For another thing, you are immediately exiting, which mean %kids
is going away. Why change a variable which is going to disappear a
nanosecond later anyway? You probably want the delete to be in the
SIG{CHLD} handler, so that it occurs in the parent process rather than the
doomed child.
...
> kill HUP => -$$;
In perl, you want to negate the signal, not the pid. But better yet,
once you fix your code dealing with %kids, kill them explicitly.
kill HUP => keys %kids.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Wed, 30 Nov 2005 16:56:09 -0600
From: Spin <cNaOlSePbA@MvPeLtEsAtSaEr.com>
Subject: lookfor failure in SerialPort
Message-Id: <11osbg5ijm0nmf1@corp.supernews.com>
I am using Win32::SerialPort 0.19 and am having trouble getting the
lookfor to work. My understanding is that lookfor(1) should sit and wait
to read one character coming inbound on my serial port.
This is the sub that wraps the lookfor:
sub waitfor {
my $debug = 'y';
$ob->lookclear; # clear buffers
my $gotit = "";
my $response = shift;
$ob->are_match($response);
print "DEBUG: Waiting for \"$response\".\n" if $debug;
for (;;) {
return unless (defined ($gotit = $ob->lookfor(1)));
if ($gotit ne "") {
my ($match, $after, $pattern) = $ob->lastlook;
print "DEBUG: Got .\"$gotit$match$after\".\n" if $debug;
return $match;
}
return if ($ob->reset_error);
}
}
This is some of the context in which it is called:
while ($in) {
$loc = $ob->read(1);
if ($loc) {
# do stuff
} else {
$ob->write(chr(05)); # send <ENQ>
waitfor(chr(06)) or die; # wait for <ACK>
...send next piece etc
}
}
This is the output I get from the sub and the die:
DEBUG: Waiting for "?".
Died at C:\horiba_pentra60Cplus.pl line 259, <UPLOAD> line 2.
(in cleanup) Can't call method "Call" on an undefined value at
C:/Perl/site/lib/Win32API/CommPort.pm line 211, <UPLOAD> line 2 during
global destruction.
Outbound and inbound communications are working otherwise. I am using
Portmon and it indicates that the chr(05) goes out successfully, there
is one read on the port which returns with length of 0 and then the port
closes.
Troubleshooting help or any advice greatfully received.
Regards,
Spin
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8725
***************************************