[25550] in Perl-Users-Digest
Perl-Users Digest, Issue: 7794 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 17 18:05:59 2005
Date: Thu, 17 Feb 2005 15:05:37 -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 Thu, 17 Feb 2005 Volume: 10 Number: 7794
Today's topics:
Re: \Q acts differently in s/// and m// operations <nospam-abuse@ilyaz.org>
Re: backticks with threads or forks hang program <zentara@highstream.net>
DBI not generating expected error messages <pat@patmail.com>
Re: DOM sub trees whilst SAX'ing in perl? <mirod@mirod.org>
Re: DOM sub trees whilst SAX'ing in perl? <bugbear@trim_papermule.co.uk_trim>
Re: DOM sub trees whilst SAX'ing in perl? <nospam@nospam.com>
Re: DOM sub trees whilst SAX'ing in perl? <bugbear@trim_papermule.co.uk_trim>
Re: DOM sub trees whilst SAX'ing in perl? <nospam@nospam.com>
Re: forking & (mysql)sockets xhoster@gmail.com
hash counter <lskatz@gmail.com>
Re: hash counter <1usa@llenroc.ude.invalid>
Re: hash counter <lskatz@gmail.com>
Re: hash counter <jl_post@hotmail.com>
Re: hash counter <lskatz@gmail.com>
Re: hash counter <spamtrap@dot-app.org>
Re: hash counter <sbryce@scottbryce.com>
Re: hash counter <jl_post@hotmail.com>
Re: Hash references & parsing HTML with HTML::Parser <grabek@invalid.com>
Re: Hash references & parsing HTML with HTML::Parser <glex_nospam@qwest.invalid>
Re: Hash references & parsing HTML with HTML::Parser (Gary E. Ansok)
Re: Hash references & parsing HTML with HTML::Parser <grabek@invalid.com>
Re: Hash references & parsing HTML with HTML::Parser <grabek@invalid.com>
Re: ithreads + signals on modern Unices <Thomas.Jahns@epost.de>
locking directories ofer@netapt.com
Re: locking directories <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 17 Feb 2005 22:57:33 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: \Q acts differently in s/// and m// operations
Message-Id: <cv37gt$bk$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Bob Walton
<see.sig@rochester.rr.com>], who wrote in article <crTQd.15377$H05.4135@twister.nyroc.rr.com>:
> Well, the "replacement" in the s/// operator is a *string*, not a
> regexp. And that string is processed per qq().
Correct.
> For that, \Q has
> a different meaning
Wrong. \Q has the same meaning everywhere.
> -- all non-word characters following \Q are quoted
That's it.
> In the m// regexp, it is the *regexp* characters that are quoted,
> and not any characters in the matched string.
Wrong. But since quoting some characters is a NOOP (e.g., \: matches
the same as : ), the semantic is somewhat similar to what you wrote -
which is probably the reason for your confusion.
> You probably should simply dispense with the \Q and \E in your
> replacement string.
Without reading the mind of the author, giving any advice does not
make sense. I would just note that
s(REX)(\Q$var);
is the same as
$repl = quotemeta $var;
s(REX)($repl);
(but the first version is much harder to debug).
Hope this helps,
Ilya
------------------------------
Date: Thu, 17 Feb 2005 12:24:56 -0500
From: zentara <zentara@highstream.net>
Subject: Re: backticks with threads or forks hang program
Message-Id: <g2k911h4vbqsism71o4ek1i0e0jph9d21r@4ax.com>
On 16 Feb 2005 05:18:06 -0800, warren@netlab.co.za (Warren) wrote:
>Greetings
>
>The function of the script below is to execute scripts (perl) at
>regular intervals. As I have no idea how long these external scripts
>will take to excute I decided to use threads and execute each script
>from its own thread. This appeared to work until the number of threads
>increased. The greater the number of threads the more lightly the
>program will hang. As the output of the external scripts is required
>the backticks are used.
Well I'll tell you one little rule of thumb about threads.....all
threads are sharing the same process, so if you call a system
command from a thread, all threads will be blocked until it returns.
The worst mistake you can make in a thread, is call exec. That
will replace "all threads" with the exec'd process.
What you want to do in the thread, is do a "fork and exec" to
run your command.
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: Thu, 17 Feb 2005 19:54:40 GMT
From: "patrickg" <pat@patmail.com>
Subject: DBI not generating expected error messages
Message-Id: <4E6Rd.88814$qB6.62565@tornado.tampabay.rr.com>
Hey all - new to Perl and DBI, so just trying to get an understanding of
things. I copied some sample code from the Perl DBI book in the error
checking section, but I can't seem to get any of the error messages that I
expect. Instead, the program crashes and I get the popup box stating " Perl
Command Line Interpreter has encountered a problem and needs to close.". Can
someone tell me why none of these error messages are are being displayed
when I deliberately make a typo (ie. bad password, malformed SQL, etc) to
cause an error? (I've tried all the combinations of setting the PrintError
and RaiseError).
use strict;
use DBI;
#deliberately mistyped password 'tiger' to try to generate error ...
my $dbh = DBI->connect( 'dbi:Oracle:orcl',
'scott',
'tigre',
{ RaiseError => 0,
PrintError => 1}
)|| die "Database connection not made: $DBI::errstr";
my $sth;
my $sql;
my ($obj1, $obj2);
#deliberately mistyped 'table_name' to try to generate error ...
$sql = qq{SELECT tabel_name, column_name
FROM user_tab_cols};
$sth = $dbh->prepare($sql) or die "Can't prepare: ", $dbh->errstr;
$sth->execute() or die "Can't execute: ", $dbh->errstr;
$sth->bind_columns( undef, \$obj1, \$obj2 );
while( $sth->fetch() ) {
print "$obj1\t$obj2\n";
}
$sth->finish();
TIA!
patrick
------------------------------
Date: Thu, 17 Feb 2005 15:21:02 +0100
From: Michel Rodriguez <mirod@mirod.org>
Subject: Re: DOM sub trees whilst SAX'ing in perl?
Message-Id: <4214ab5c$0$6301$5fc30a8@news.tiscali.it>
bugbear wrote:
> I need to process some XML files that are rather large.
> However their structure may usefully be expressed
> as
> <ELEMENT FILE (RECORD)+>
> .
> .
> .
>
> Each record is a few Kb. The files are many 10's of Megabytes.
>
> I would (dearly) like to use DOM to process each record,
> since it's easier to get my head round than SAX events.
>
> But I don't want to pull the whole file into
> a DOM tree; it's too big.
>
> These people have come up with a perfect (and obvious?)
> solution:
> http://www.devsphere.com/xml/saxdomix/
>
> But I'm coding in a Perl environment.
>
> Is there a similar Module, generating separate
> DOM sub trees for Perl?
It looks like what XML::Twig does, except XML::Twig is not SAX/DOM based.
--
mirod
------------------------------
Date: Thu, 17 Feb 2005 16:43:59 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: DOM sub trees whilst SAX'ing in perl?
Message-Id: <4214c9d7$0$45188$ed2e19e4@ptn-nntp-reader04.plus.net>
Michel Rodriguez wrote:
> bugbear wrote:
>> These people have come up with a perfect (and obvious?)
>> solution:
>> http://www.devsphere.com/xml/saxdomix/
>>
>> But I'm coding in a Perl environment.
>>
>> Is there a similar Module, generating separate
>> DOM sub trees for Perl?
>
>
> It looks like what XML::Twig does, except XML::Twig is not SAX/DOM based.
>
OK. That does the right thing; I'd prefer to stay with standards
(i.e. SAX and DOM) if possible. I'll keep looking, and bear
XML::Twig in mind as a fall back position.
BugBear
------------------------------
Date: Thu, 17 Feb 2005 18:05:33 +0100
From: "SL" <nospam@nospam.com>
Subject: Re: DOM sub trees whilst SAX'ing in perl?
Message-Id: <4214ce61$0$6595$8fcfb975@news.wanadoo.fr>
> >> Is there a similar Module, generating separate
> >> DOM sub trees for Perl?
> >
> >
> > It looks like what XML::Twig does, except XML::Twig is not SAX/DOM
based.
> >
>
> OK. That does the right thing; I'd prefer to stay with standards
> (i.e. SAX and DOM) if possible. I'll keep looking, and bear
> XML::Twig in mind as a fall back position.
>
I haven't used it since a while, but there is (or was) a package doing what
you want on CPAN: DocSplitter in XML::SAX::Machines. It allows you to split
a SAX stream into several smaller documents by throwing a startDocument()
and endDocument() event before and after a particular element. For instance,
you may split your stream on each RECORD element, so that each filter below
in the pipeline process RECORD element as the root element of distinct
document. This is is useful in particular with the filtre XML::Filter::XSLT
by Matt Sergeant. If you want to merge again the results of the
transformation into a big document, you may use a "Merger" in the pipeline
package; it works with the splitter for removing the extra startDocument()
and endDocument() events. Machines provide several facilities for dealing
with SAX pipeline.
HTH,
SL
------------------------------
Date: Thu, 17 Feb 2005 18:35:38 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: DOM sub trees whilst SAX'ing in perl?
Message-Id: <4214e402$0$67597$ed2619ec@ptn-nntp-reader01.plus.net>
SL wrote:
>>>>Is there a similar Module, generating separate
>>>>DOM sub trees for Perl?
>>>
>>>
>>>It looks like what XML::Twig does, except XML::Twig is not SAX/DOM
>
> based.
>
>>OK. That does the right thing; I'd prefer to stay with standards
>>(i.e. SAX and DOM) if possible. I'll keep looking, and bear
>>XML::Twig in mind as a fall back position.
>>
>
>
> I haven't used it since a while, but there is (or was) a package doing what
> you want on CPAN: DocSplitter in XML::SAX::Machines. It allows you to split
> a SAX stream into several smaller documents by throwing a startDocument()
> and endDocument() event before and after a particular element. For instance,
> you may split your stream on each RECORD element, so that each filter below
> in the pipeline process RECORD element as the root element of distinct
> document. This is is useful in particular with the filtre XML::Filter::XSLT
> by Matt Sergeant. If you want to merge again the results of the
> transformation into a big document, you may use a "Merger" in the pipeline
> package; it works with the splitter for removing the extra startDocument()
> and endDocument() events. Machines provide several facilities for dealing
> with SAX pipeline.
So how do I get my DOM(s)?
BugBear
------------------------------
Date: Thu, 17 Feb 2005 20:23:44 +0100
From: "SL" <nospam@nospam.com>
Subject: Re: DOM sub trees whilst SAX'ing in perl?
Message-Id: <4214eeb0$0$17278$8fcfb975@news.wanadoo.fr>
> So how do I get my DOM(s)?
Look into the XML::Filter::XSLT::LibXSLT filter : it used
XML::LibXML::SAX::Builder for building a DOM using the SAX events received.
SL
------------------------------
Date: 17 Feb 2005 16:52:49 GMT
From: xhoster@gmail.com
Subject: Re: forking & (mysql)sockets
Message-Id: <20050217115249.827$40@newsreader.com>
arnevt@sloeber.office.xs4all.be wrote:
> Hi
>
> I'm writing a small getcounter script, and due to growing pains, I want
> it to fork all it's queries (to a max of 5 forks, and then waiting to
> start a new one until someone get's free).
> I had a small issue with Net::SNMP being defined before it was forked,
> and all sessions were using the same src-port (with the well known
> consequenses). Now there is 1 socket opened to a mysql-server. I was
> wondering: all forks have to update the database with their
> particular result. Would it cause problems if 2 or more forks were doing
> an update through the same $socket (at the same time)?
I don't know what a "getcounter" script is, and have no experience with
Net::SNMP, but I do know that for general databse work, mysql connections
should be opened after the fork(s), not before.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 17 Feb 2005 14:21:50 -0800
From: "Lee" <lskatz@gmail.com>
Subject: hash counter
Message-Id: <1108678910.569798.145050@c13g2000cwb.googlegroups.com>
Hey I have a hash table with many many keys. In each entry, the value
is a counter and so my code goes something like:
my %hash=();
while (statement){
$key="blabla";
if (!$hash{$key}){
$hash{$key}=1;
}
elsif ($hash{$key}){
$hash{$key}++;
}
}
How would I speed this up? Someone told me that using the following
code instead would work, but it hasn't.
my %hash=();
while (statement){
$key="blabla";
$hash{$key}++;
}
------------------------------
Date: 17 Feb 2005 22:24:49 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: hash counter
Message-Id: <Xns9600B124AEC3Basu1cornelledu@132.236.56.8>
"Lee" <lskatz@gmail.com> wrote in news:1108678910.569798.145050
@c13g2000cwb.googlegroups.com:
> Hey I have a hash table with many many keys. In each entry, the value
> is a counter and so my code goes something like:
Please post the smallest *real* program that demonstrates your problem.
Please read the posting guidelines for this group to learn how you can help
others help you.
Sinan.
------------------------------
Date: 17 Feb 2005 14:36:37 -0800
From: "Lee" <lskatz@gmail.com>
Subject: Re: hash counter
Message-Id: <1108679797.262582.326530@z14g2000cwz.googlegroups.com>
Are you kidding me? I thought that was good pseudocode that anyone
[who could help me] would be able to understand. I'll come up with
something later that would be short and readable if no one can help me
based on that. Promise.
Anyway, any answers in the meantime would be greatly appreciated. And
I will send you flowers.
------------------------------
Date: 17 Feb 2005 14:47:49 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: hash counter
Message-Id: <1108680469.854055.255670@c13g2000cwb.googlegroups.com>
Lee wrote:
>
> Are you kidding me? I thought that was good pseudocode that
> anyone [who could help me] would be able to understand.
It's not that we don't understand your pseudocode, Lee -- it's just
that we can't figure out why the code that was given to you doesn't
work.
In other words, the code that was give to you looks all right to me.
There doesn't seem to be anything wrong with it, so the problem
probably lies somewhere else. But all you said was: "...using the
following code instead would work, but it hasn't." That doesn't help
us figure out your problem, since everything looks all right and we
aren't given enough information to faithfully reproduce your problem.
It would help us if you could give us the exact code you wrote and the
exact error message you were given. But giving us pseudocode and
saying something like "it doesn't work" doesn't always allow us to
pinpoint the problem in question.
------------------------------
Date: 17 Feb 2005 14:52:30 -0800
From: "Lee" <lskatz@gmail.com>
Subject: Re: hash counter
Message-Id: <1108680750.013559.325410@z14g2000cwz.googlegroups.com>
okay then I'd like to rephrase my question:
Is it legal to do this without initializing that one entry?
$hash{$key}++;
There are no errors associated with it but it never adds. I'll come up
with real code for you later. Thanks.
------------------------------
Date: Thu, 17 Feb 2005 18:00:27 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: hash counter
Message-Id: <PKednW6KA5eWv4jfRVn-oQ@adelphia.com>
Lee wrote:
> okay then I'd like to rephrase my question:
>
> Is it legal to do this without initializing that one entry?
> $hash{$key}++;
Yes, it is. The entry associated with $key will be created as needed.
A simple one-liner can verify that:
sherm$ perl -e '$hash{"foo"}++; print $hash{"foo"}, "\n"'
1
sherm$
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Thu, 17 Feb 2005 16:03:06 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: hash counter
Message-Id: <2padncbACfc1v4jfRVn-sQ@comcast.com>
Lee wrote:
> Is it legal to do this without initializing that one entry?
> $hash{$key}++;
>
> There are no errors associated with it but it never adds. I'll come up
> with real code for you later. Thanks.
use strict;
use warnings;
my %hash;
my $key = 'key';
$hash{$key}++;
print $hash{$key};
This prints 1 as expected. You will have to show us real code.
------------------------------
Date: 17 Feb 2005 15:03:59 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: hash counter
Message-Id: <1108681439.865911.215350@z14g2000cwz.googlegroups.com>
Lee wrote:
>
> Is it legal to do this without initializing that one entry?
> $hash{$key}++;
Yes, even when "use strict;" and "use warnings;" is in use.
> There are no errors associated with it but it never adds.
> I'll come up with real code for you later. Thanks.
That's strange, but the real error probably lies elsewhere. A
short, sample program would help us a lot in finding your error.
------------------------------
Date: Thu, 17 Feb 2005 19:37:51 +0000 (UTC)
From: Lukasz Grabun <grabek@invalid.com>
Subject: Re: Hash references & parsing HTML with HTML::Parser
Message-Id: <slrnd19se8.2p8.grabek@localhost.localdomain>
On Wed, 16 Feb 2005 19:10:20 +0000 (UTC), Lukasz Grabun wrote:
> So, I am still working on my simple HTML parser. Now, following your
> tips, I am using HTML::Parser. I've made one simple script with that
> package and now want to make something more serious.
It's halfway done. I've improved it a bit, according to your tips. If
someone interested, here it is. If anyone could point me any
improvements that can be made (surely it can be written more
idiomatically, from the lack of better term i.e. more perlish), I'd be
most grateful (please excuse me long lines, I didn't want to wrap them
as not to break the script).
#!/usr/bin/perl
# ider - a simple script that adds id attributes to
# following HTML elements:
# <p>, <blockquote>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>,
# <ul>, <ol>, <li>, <dl>, <dd>, <dt>, <q>
# Author: Lukasz Grabun, 2005.
use strict;
use warnings;
package Ider;
use base "HTML::Parser";
my $number = 5;
my $input;
my $prefix;
sub start {
my ($self, $tag, $attr, $attrseq, $origtext) = @_;
if ( !($attr->{'id'}) && ($tag =~ /^blockquote$|^p$|^h[1-6]$|^ul$|^ol$|^li$|^dl$|^dd$|^dt$|^q$/))
{
print "<$tag ";
foreach my $i (@$attrseq) { print $i, qq(="$attr->{$i}" ); }
if ((@$attrseq)) { print "id=\"$prefix-$number\">"; } else { print "id=\"$prefix-$number\">"; }
$number += 5;
}
else { print $origtext; }
}
sub text { my ($self, $text) = @_; print $text; }
sub comment { my ($self, $comment) = @_; print "<!-- ", $comment, " -->"; }
sub end { my ($self, $tag, $origtext) = @_; print $origtext; }
($input, $prefix) = @ARGV;
open (INPUT, "<$input") || die "Cannot open file $input: $!\n";
unless ($prefix) { $prefix = "pref"; }
my $p = new Ider;
while (<INPUT>) { $p -> parse($_); }
$p->eof;
------------------------------
Date: Thu, 17 Feb 2005 14:09:14 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Hash references & parsing HTML with HTML::Parser
Message-Id: <JR6Rd.19$Qz6.1048@news.uswest.net>
Lukasz Grabun wrote:
> On Wed, 16 Feb 2005 19:10:20 +0000 (UTC), Lukasz Grabun wrote:
>
>
>>So, I am still working on my simple HTML parser. Now, following your
>>tips, I am using HTML::Parser. I've made one simple script with that
>>package and now want to make something more serious.
>
>
> It's halfway done. I've improved it a bit, according to your tips. If
> someone interested, here it is. If anyone could point me any
> improvements that can be made (surely it can be written more
> idiomatically, from the lack of better term i.e. more perlish), I'd be
> most grateful (please excuse me long lines, I didn't want to wrap them
> as not to break the script).
>
> #!/usr/bin/perl
>
> # ider - a simple script that adds id attributes to
> # following HTML elements:
> # <p>, <blockquote>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>,
> # <ul>, <ol>, <li>, <dl>, <dd>, <dt>, <q>
> # Author: Lukasz Grabun, 2005.
>
> use strict;
> use warnings;
>
> package Ider;
>
> use base "HTML::Parser";
>
> my $number = 5;
> my $input;
> my $prefix;
>
> sub start {
> my ($self, $tag, $attr, $attrseq, $origtext) = @_;
>
> if ( !($attr->{'id'}) && ($tag =~ /^blockquote$|^p$|^h[1-6]$|^ul$|^ol$|^li$|^dl$|^dd$|^dt$|^q$/))
The regex can be improved quite a bit, either by using
/^(?:blockquote|p|etc...)$/ or make a hash of each element:
my %elements_to_report = map { $_ => 1 } qw(block p h1 h2);
then your regex is eliminated and simply becomes $elements_to_report{$tag}
> {
> print "<$tag ";
> foreach my $i (@$attrseq) { print $i, qq(="$attr->{$i}" ); }
> if ((@$attrseq)) { print "id=\"$prefix-$number\">"; } else { print "id=\"$prefix-$number\">"; }
What's the difference???
> $number += 5;
> }
Improve your choice of variable names. $i isn't good.
print "<$tag ";
foreach ... { print .. }
print "id=\"$prefix-$number\">";
$number+=5;
> else { print $origtext; }
> }
>
> sub text { my ($self, $text) = @_; print $text; }
> sub comment { my ($self, $comment) = @_; print "<!-- ", $comment, " -->"; }
> sub end { my ($self, $tag, $origtext) = @_; print $origtext; }
>
A little formatting goes a long way. Give perltidy a try.
Not sure why you'd have any of the following stuff in your 'Ider' package.
> ($input, $prefix) = @ARGV;
>
> open (INPUT, "<$input") || die "Cannot open file $input: $!\n";
> unless ($prefix) { $prefix = "pref"; }
$prefix = 'pref' unless $prefix; #more readable??
>
> my $p = new Ider;
> while (<INPUT>) { $p -> parse($_); }
Look a the parse_file method.
> $p->eof;
>
>
>
>
------------------------------
Date: Thu, 17 Feb 2005 20:18:00 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Hash references & parsing HTML with HTML::Parser
Message-Id: <cv2u5o$spd$1@naig.caltech.edu>
In article <slrnd19se8.2p8.grabek@localhost.localdomain>,
Lukasz Grabun <lgrabun@invalid.com> wrote:
>It's halfway done. I've improved it a bit, according to your tips. If
>someone interested, here it is. If anyone could point me any
>improvements that can be made (surely it can be written more
>idiomatically, from the lack of better term i.e. more perlish), I'd be
>most grateful (please excuse me long lines, I didn't want to wrap them
>as not to break the script).
> if ((@$attrseq)) { print "id=\"$prefix-$number\">"; } else { print "id=\"$prefix-$number\">"; }
What is this test doing? It looks like the two actions are exactly the
same, so why not just
print "id=\"$prefix-$number\">";
or
print qq/id="$prefix-$number">/;
These two do the same thing; the qq// is just an alternate delimiter
that would mean not needing to backslash the quotes. I think it's a
little easier to read using qq//, but it's not a big deal.
- Gary
------------------------------
Date: Thu, 17 Feb 2005 20:27:52 +0000 (UTC)
From: Lukasz Grabun <grabek@invalid.com>
Subject: Re: Hash references & parsing HTML with HTML::Parser
Message-Id: <slrnd19vc1.2p8.grabek@localhost.localdomain>
On Thu, 17 Feb 2005 20:18:00 +0000 (UTC), Gary E. Ansok wrote:
>> if ((@$attrseq)) { print "id=\"$prefix-$number\">"; } else { print "id=\"$prefix-$number\">"; }
>
> What is this test doing? It looks like the two actions are exactly the
> same, so why not just
Erm, I can't tell now why it's there. However, in previous versions of
the script, depending on whether the tag contained any attributes or
none the extra space before "id" attribute was required. It vapourised.
Well, it works as it is. I got rid of unecessary check. Thanks for
letting me know.
------------------------------
Date: Thu, 17 Feb 2005 20:33:24 +0000 (UTC)
From: Lukasz Grabun <grabek@invalid.com>
Subject: Re: Hash references & parsing HTML with HTML::Parser
Message-Id: <slrnd19vmd.2p8.grabek@localhost.localdomain>
On Thu, 17 Feb 2005 14:09:14 -0600, J. Gleixner wrote:
> my %elements_to_report = map { $_ => 1 } qw(block p h1 h2);
> then your regex is eliminated and simply becomes $elements_to_report{$tag}
I was thinking of something like this though I couldn't figure out the
way to form the question :-) Thanks, this is most helpful.
> A little formatting goes a long way. Give perltidy a try.
Will take a look.
> Not sure why you'd have any of the following stuff in your 'Ider' package.
You mean? How should I "remove" it from the package Ider? By adding
package main; line?
> Look a the parse_file method.
Sure it does. Thanks.
------------------------------
Date: 17 Feb 2005 21:26:35 +0100
From: Thomas Jahns <Thomas.Jahns@epost.de>
Subject: Re: ithreads + signals on modern Unices
Message-Id: <87650r2aro.fsf@ID-48333.user.dfncis.de>
Thomas Jahns <Thomas.Jahns@epost.de> writes:
> I wish to make a background application I told to 'use threads;' also
> react nicely to a SIGHUP (and reread configuration). perldoc perlthrtut
> tells me not to mix signals and ithreads but the other aspects to
> consider are as follows:
>
> - I don't care for portability to Win32, pre-X MacOS, MVS or whatever
> platforms may also provide a Perl implementation. I just need the
> program to run on relatively modern Unices (i.e. pthreads and POSIX
> sigaction will be available).
>
> - perlthrtut also tells me 'use Thread;' will break real soon and isn't
> so great to begin with, and Thread::Queue which my program already
> uses is--surprise--not meant to work with Thread but threads anyway.
>
> So I seek a description of signal semantics for the systems outlined
> when using ithreads. Is there such documentation available? I searched
> but apart from the Perl source couldn't find anything useful (not that I
> didn't get many google hits, but what I got was either outdated or a
> repetition of the message from perlthrtut).
>
> Since the I really like the ease at which Perl allows me to write
> programs for Unix/Linux I'd really hate to turn my program into ten
> times the number of code lines of C.
So does the lack of answers mean, that I
- I did not describe my intended application clearly enough?
- I should take this question to a Unix programming group?
- I violated etiquette really badly?
- noone except me cares about using threads and still handling
signals, after all it has to work every time one calls system(), or
not?
Please, any pointer will do, even if it means I'll have to either dig
through the Perl or rather rewrite in C.
Thanks for any input,
Thomas Jahns
--
"Computers are good at following instructions,
but not at reading your mind."
D. E. Knuth, The TeXbook, Addison-Wesley 1984, 1986, 1996, p. 9
------------------------------
Date: 17 Feb 2005 14:08:02 -0800
From: ofer@netapt.com
Subject: locking directories
Message-Id: <1108678082.587443.222580@g14g2000cwa.googlegroups.com>
Does anyone know how to lock a directory? I tried the standard flock
call, and it didn't like it:
my $dir = "/netapp/ofer/somedir";
print "opening $dir\n";
opendir( SOMEDIR, $dir ) or die( $! );
print "locking $dir\n";
flock( SOMEDIR, LOCK_EX ) or die( $! );
print "locked! sleeping\n";
sleep( 999 );
print "unlocking $dir\n";
flock( SOMEDIR, LOCK_UN ) or die( $! );
print "closing $dir\n";
closedir( SOMEDIR ) or die( $! );
print "done\n";
[onave@thebox ~] ./foo.pl
opening /netapp/ofer/somedir
locking /netapp/ofer/somedir
flock() on unopened filehandle SOMEDIR at ./foo.pl line 19.
(Are you trying to call flock() on dirhandle SOMEDIR?)
Bad file descriptor at ./foo.pl line 19.
I've done some searching on CPAN and google with no luck so far.
-ofer
------------------------------
Date: 17 Feb 2005 22:14:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: locking directories
Message-Id: <Xns9600AF66F884asu1cornelledu@132.236.56.8>
ofer@netapt.com wrote in news:1108678082.587443.222580
@g14g2000cwa.googlegroups.com:
> Does anyone know how to lock a directory?
What makes you think you can or should be able to lock a directory?
> I tried the standard flock call, and it didn't like it:
Is there a reason to expect otherwise?
C:\> perldoc -f flock
flock FILEHANDLE,OPERATION
Calls flock(2), or an emulation of it, on FILEHANDLE.
...
> I've done some searching on CPAN and google with no luck so far.
If you actually explained what you are trying to do, we might be able to
help. But, please, before proceeding further, read the posting guidelines
for this group to learn how you can help others help you.
Sinan.
------------------------------
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 7794
***************************************