[26142] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8333 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 18 18:05:30 2005

Date: Thu, 18 Aug 2005 15:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 18 Aug 2005     Volume: 10 Number: 8333

Today's topics:
    Re: coding style and performance <ngoc@yahoo.com>
        How to detect a dead parent? <markm@chiark.greenend.org.uk>
    Re: Obtaining verbose info for http transfers. <emschwar@pobox.com>
    Re: Organizing data for readability and efficiency <Mark.Seger@hp.com>
        Readonly + Exporter <jens.luedicke@gmail.com>
        regex help <buki@gmx.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 18 Aug 2005 23:28:26 +0200
From: ngoc <ngoc@yahoo.com>
Subject: Re: coding style and performance
Message-Id: <4304fd79@news.broadpark.no>


Thanks guys. You help me much.


------------------------------

Date: 18 Aug 2005 21:19:08 +0100 (BST)
From: Mark Mackey <markm@chiark.greenend.org.uk>
Subject: How to detect a dead parent?
Message-Id: <uMc*pTtWq@news.chiark.greenend.org.uk>

Hi all.

I've got a daemon script which forks off several children which go and
do funky things with sockets and the like. I need to make sure that the
children are killed when the parent dies, so I've installed signal
handlers in the parent which kill HUP => -$$; when the parent exits or
receives a signal.

However, under some circumstances the parent dies (if it's kill -9'ed,
for example) without signalling the children, which then live a happy
existence not knowing that they should be dead. This is a problem.

So, the question is, how can a child detect that its parent is dead?  I
tried using getppid() to test if the ppid had becore equal to 1 (which
is what happens after the parent exits), but after frustrating hours of
debugging I found a web page which pointed out the AFAIK undocumented
fact that Perl caches the ppid on Linux and so will always return the
same value in a script. Grrr. I also tried doing a kill 0 => getppid;,
which works in theory but not in practice because the parent is uid 0
and the children drop privileges, so the children aren't priviledged to
signal the parent (even kill 0, which doesn't actually send a signal.
Double Grrr.)

So, any suggestions? I've run out of ideas that aren't really hacky
(like faffing around with sockets, or reading /proc directly, or running
'ps' and parsing the output, or other horrible things). A way of
ensuring that the children die directly when the parent does would be even
better.

Oh, I know about Linux::Pid, but (a) I need to install this code on
multiple machines not under my control so getting random things out of
CPAN is a pain, and (b) it depends on 'use Inline C', which is beta and
looks a bit hacky.

-- 
Mark Mackey   http://www.swallowtail.org/
code code code code code code code code code code code code code bug code co
de code code code bug code code code code code code code code code code code
code code code code code code code code code code code code code code code c


------------------------------

Date: Thu, 18 Aug 2005 15:52:03 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Obtaining verbose info for http transfers.
Message-Id: <etou0hmc3r0.fsf@wilson.emschwar>

ko <kuujinbo@hotmail.com> writes:
> sub verbose_http {
>    push my @urls, shift;
>    while (my $url = shift @urls) {

What's the point of this?  Why not just
sub verbose_http {
     my $url = shift;

<snip rest of code>

-=Eric


------------------------------

Date: Thu, 18 Aug 2005 16:30:59 -0400
From: Mark Seger <Mark.Seger@hp.com>
Subject: Re: Organizing data for readability and efficiency
Message-Id: <4304f005@usenet01.boi.hp.com>


> If you are considering making the choice between arrays and hashes based on
> the performance of single look-ups into each (rather than by whether the
> nature of your data best fits an array or best fits a hash), then I say you
> are engaging in micro-optimization.  Perhaps this is the nub of your
> question, so let me repeat.  The difference between array access and hash
> access is small enough that if you are concerned about it, only actual
> tests on actual data will be satifactory.

Let me try again, I'm not concerned about the performance of single 
lookups, I'm concerned with at least hundreds of thousands.  I was 
hoping for a simple answer but if that's not going to happen I also 
agree with you that the real answer is to measure it and I guess that's 
what I'll end up doing.
-mark


------------------------------

Date: Thu, 18 Aug 2005 22:48:25 +0200
From: Jens Luedicke <jens.luedicke@gmail.com>
Subject: Readonly + Exporter
Message-Id: <4304f422$0$24160$9b4e6d93@newsread4.arcor-online.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Hiya...

I want to export a few Readonly scalars into the callers namespace. They
 are exported, but without their assigned value? If I leave the 'my'
away it works but I'm not sure why. Example code below.

any hints?


TIA,
jens


package Constants;

use Readonly;

require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw($LEFT $RIGHT $TRUE $FALSE);

Readonly my $LEFT  => 0;
Readonly my $RIGHT => 1;

Readonly my $TRUE  => 1;
Readonly my $FALSE => 0;

1;


- --
Jens Luedicke
web: http://perldude.de

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDBPQZiCvkc4H0gTERAtEzAKCEK5u/46AdyADkd77IZsm3u96lTwCdH4SV
SzsK4i/j5KoxOLRJ6NHEbdU=
=Um1C
-----END PGP SIGNATURE-----


------------------------------

Date: Thu, 18 Aug 2005 22:09:16 +0200
From: Andreas Bauer <buki@gmx.net>
Subject: regex help
Message-Id: <de2ptd$8f6$1@online.de>

Hi ,

I'm a bit stuck with a regular expression. Maybe somebody's so kind
to help me a bit :)
I have the following example strings.

test_word.pdf#en:Test Word>top
/file\file.asp>top
/file/file.asp
file\start.asp?load=http://www.test.de>top
file/start.asp?load=http://www.test.de
file/start.asp?load=http://www.test.de#de:Beispiel;en:example;
file/start.asp?load=http://www.test.de#de:Beispiel;en:example;>top
file/start.asp>top
file/start.asp
file/start.asp#de:Beispiel;en:example;
file/start.asp#de:Beispiel;en:example;>top
/file/start.asp#de:Beispiel;en:example;>top
http://www.start.de
http://www.start.de?load=http://www.test.de#de:Beispiel;en:example;>top
ftp://ftp.test.tt#en:example page
 ...

I need a regex that extracts me
- the part (file, file/, ftp://ftp.test.tt,start.asp,etc) before 
?load=... whereas ?load ist optional
- the the uri after ?load=. That normally ends at # or > or
- the part after > at the end (optional)
- finally the part 'example' between #de:Beispiel;en:.. and the end of 
the line or '>top'

For the examples starting with 'file' the following regex works fine:
((.*)[(/|\\)])(.*\.asp)(\?load=(.*)#)?((.*;en:(.*));)?(>(.*)$)?

But I don't succeed in expanding the regex to match the first example 
string (test_word.pdf#en:Test Word>top)and the last three with  http://,
ftp://.

I'm quite stuck with that.
I'd appreciate any hint.

Best regards,

Andi


------------------------------

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


home help back first fref pref prev next nref lref last post