[26356] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8529 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 16 18:05:32 2005

Date: Sun, 16 Oct 2005 15:05:05 -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           Sun, 16 Oct 2005     Volume: 10 Number: 8529

Today's topics:
        core dump after alarm goes off (The Pied Typer)
    Re: core dump after alarm goes off <1usa@llenroc.ude.invalid>
    Re: core dump after alarm goes off (Anno Siegel)
    Re: Hash of array access tricks.  Sorry, long. <keeling@spots.ab.ca>
    Re: HTML::TokeParser <dvh@dvhdvhdvhdvdh.dvh>
    Re: HTML::TokeParser <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 16 Oct 2005 18:10:52 GMT
From: colonel@monmouth.com (The Pied Typer)
Subject: core dump after alarm goes off
Message-Id: <MIw4f.29012$Ge5.12624@fe10.lga>

I have several related memory- and output-intensive Perl programs.
They all have a timeout option that uses the alarm function.  The ALRM
handler goes into a temporary directory, unlinks all the files, removes
the directory, and exits.

These programs very often dump core after running the handler.
I know that they run the handler because the temporary directory
is gone afterwards.  The handler is assigned by reference:

	$SIG{ALRM} = $SIG{INT} = $SIG{TERM} = \&cleanup;

Has anybody seen anything like this?  I suspect that the trouble
may occur when an output operation is interrupted.

-:-
	I	First he deals a deadly blow,
		Then he staggers to and fro.
		His behavior would be risible
		If it only could be visible.

				--The Roguelet's ABC
-- 
Col. G. L. Sicherman
colonel@mail.monmouth.com


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

Date: Sun, 16 Oct 2005 18:27:43 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: core dump after alarm goes off
Message-Id: <Xns96F1931ED48D0asu1cornelledu@127.0.0.1>

colonel@monmouth.com (The Pied Typer) wrote in
news:MIw4f.29012$Ge5.12624@fe10.lga: 

> I have several related memory- and output-intensive Perl programs.
> They all have a timeout option that uses the alarm function.  The ALRM
> handler goes into a temporary directory, unlinks all the files,
> removes the directory, and exits.
> 
> These programs very often dump core after running the handler.
> I know that they run the handler because the temporary directory
> is gone afterwards.  The handler is assigned by reference:
> 
>      $SIG{ALRM} = $SIG{INT} = $SIG{TERM} = \&cleanup;

Please post the shortest possible program that still exhibits this
behavior. Please read the posting guidelines for this group for tips on
how to post code. That will maximize your chances of getting useful
responses as opposed to a whole bunch of people wasting time trying to
guess exactly how you are doing things. 

> -:-

The correct sig separator is dash-dash-space on a line by themselves. I
see that you actually use that delimiter properly for your name and
email address, but by including a longish sigquote with this funny
separator, you are imposing on your readers the responsibility to snip
these irrelevant lines. Please consider using a shorter signature that
is properly separated from the body of your post. 

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: 16 Oct 2005 18:40:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: core dump after alarm goes off
Message-Id: <diu6r3$g4l$1@mamenchi.zrz.TU-Berlin.DE>

The Pied Typer <colonel@monmouth.com> wrote in comp.lang.perl.misc:
> I have several related memory- and output-intensive Perl programs.
> They all have a timeout option that uses the alarm function.  The ALRM
> handler goes into a temporary directory, unlinks all the files, removes
> the directory, and exits.
> 
> These programs very often dump core after running the handler.
> I know that they run the handler because the temporary directory
> is gone afterwards.  The handler is assigned by reference:
> 
> 	$SIG{ALRM} = $SIG{INT} = $SIG{TERM} = \&cleanup;
> 
> Has anybody seen anything like this?  I suspect that the trouble
> may occur when an output operation is interrupted.

There is always a potential problem with doing too much in a signal
handler, how much of a problem depends on the Perl version.

Assuming you want to do the cleanup after a normal end of the program too,
I'd put the cleanup routine in an END block.  Then all your signal handlers
have to do is die, or even exit, so as to trigger the END block.  An uncaught
signal, like any exception, bypasses END.  Untested:

    $SIG{ALRM} = $SIG{INT} = $SIG{TERM} = sub { exit };

    # etc.

    END { cleanup() }

I bet that will be less troublesome.  If you want to bypass cleanup in
some cases, you can use a flag variable, or POSIX::_exit.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Sun, 16 Oct 2005 18:44:18 GMT
From: "s. keeling" <keeling@spots.ab.ca>
Subject: Re: Hash of array access tricks.  Sorry, long.
Message-Id: <slrndl57s1.a0j.keeling@infidel.spots.ab.ca>

Lawrence Statton N1GAK/XE2 <lawrence@hummer.not-here.net>:
>  "s. keeling" <keeling@spots.ab.ca> writes:
> 
> > s. keeling <keeling@spots.ab.ca>:
> > >  I've built a HoA as so:
> > > 
> > >  my %prompt = (
> > >    FIRST_NAME  => [ qq(NULL), qq(NULL), qq(\tFirst name      -> ), 
> > >                     qq(You MUST supply a first name.\n) ],
> > >    LAST_NAME   => [ qq(NULL), qq(NULL), qq(\tLast name       -> ), 
> > >                     qq(You MUST supply a last name.\n) ],
> > > 
> > >  and so on.  I'd like to write to and access $prompt->{$key}[2] when
> > >  prompting a user for the name, and I'd like to stuff the reply in
> > >  $prompt{$key}[1], then compare that with $prompt->{$key}[0], which
> > >  I'll try to supply via a call to mysql.  :-)
> > 
> > I should also say for some reason it won't work if I don't declare
> > both $prompt and %prompt, ... or should I just be "my"ing the former
> 
>  perhaps this will help you understand...
> 
>  #!/usr/bin/perl

Well,it adds to the mystery.

>  %prompt at $prompt are different variables....  Just WISHING $prompt
>  to become a refrence to %prompt will not make it so.

It seems my books disagreed, as I understood them.  Now I see a
construct I hadn't seen necessary 'til now: @{$prompt->{$key}[2]}. Thx.



-- 
    Any technology distinguishable from magic is insufficiently advanced.
    (*)    http://www.spots.ab.ca/~keeling           Linux Counter #80292
    - -    Spammers! http://www.spots.ab.ca/~keeling/autospam.html
http://www.ietf.org/rfc/rfc1855.txt democracy human rights Taiwan Independence


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

Date: Sun, 16 Oct 2005 21:21:43 +0000 (UTC)
From: "DVH" <dvh@dvhdvhdvhdvdh.dvh>
Subject: Re: HTML::TokeParser
Message-Id: <diug96$jfj$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com>


Stephen Hildrey <steve@uptime.org.uk> wrote in message
news:1129484153.30203.0@doris.uk.clara.net...
> DVH wrote:
> > I'm trying to get tokeparser to fetch a series of hyperlinks and print
the
> > URL followed by the link text.
> >
> > The following script ("eurofeed.pl") gives me "Can't coerce array into
hash
> > at eurofeed.pl line 31"
> >
> > Line 31 is "if ($tag->[2]{class} and $tag->[2]{class} eq
'docSel-titleLink')
>
> You probably want ->[1] rather than ->[2]

I did. I had thought it would be tag[2] because I was looking for the third
tag within those brackets, but obviously not.

Thank you, that now works. I have a couple more questions (ah they always
do...)

Firstly, the HTML puts a lot of whitespace in the middle of the hrefs. Is
there a reasonably simple way of getting rid of that? The site is at
http://europa.eu.int/rapid/recentPressReleasesAction.do?guiLanguage=en&hits=
10 if you need to see it.

Secondly, I'm working towards getting following those hrefs and then parsing
the text I find there. Would I be better off using WWW::Mechanize to do
this?

Thanks again for your help.




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

Date: Sun, 16 Oct 2005 21:41:20 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: HTML::TokeParser
Message-Id: <Xns96F1B3F245A6asu1cornelledu@127.0.0.1>

"DVH" <dvh@dvhdvhdvhdvdh.dvh> wrote in
news:diug96$jfj$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com: 

> 
> Stephen Hildrey <steve@uptime.org.uk> wrote in message
> news:1129484153.30203.0@doris.uk.clara.net...
>> DVH wrote:
>> > I'm trying to get tokeparser to fetch a series of hyperlinks and
>> > print the URL followed by the link text.
>> >
>> > The following script ("eurofeed.pl") gives me "Can't coerce array
>> > into hash at eurofeed.pl line 31"
>> >
>> > Line 31 is "if ($tag->[2]{class} and $tag->[2]{class} eq
> 'docSel-titleLink')
>>
>> You probably want ->[1] rather than ->[2]
> 
> I did. I had thought it would be tag[2] because I was looking for the
> third tag within those brackets, but obviously not.
> 
> Thank you, that now works. I have a couple more questions (ah they
> always do...)
> 
> Firstly, the HTML puts a lot of whitespace in the middle of the hrefs.

ITYM "the HTML contains".


> Is there a reasonably simple way of getting rid of that? The site is
> at 
> http://europa.eu.int/rapid/recentPressReleasesAction.do?
guiLanguage=en&
> hits= 10 if you need to see it.
> 
> Secondly, I'm working towards getting following those hrefs and then
> parsing the text I find there. Would I be better off using
> WWW::Mechanize to do this?

#!/usr/bin/perl

use strict;
use warnings;

use HTML::LinkExtractor;
use LWP::Simple;

my $url = q{http://europa.eu.int/rapid/recentPressReleasesAction.do?
guiLanguage=en};
my $html = get $url;

die "Cannot get <$url>\n" unless $html;

my $lx = HTML::LinkExtractor->new;
$lx->parse(\$html);

use Data::Dumper;

for my $link ( @{ $lx->links } ) {
   if ($link->{class} eq 'docSel-formatLink') {
      print Dumper $link;
   }
}


__END__

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

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


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