[26339] in Perl-Users-Digest
Perl-Users Digest, Issue: 8514 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 12 00:07:11 2005
Date: Tue, 11 Oct 2005 21:05:03 -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 Tue, 11 Oct 2005 Volume: 10 Number: 8514
Today's topics:
Re: getElementsByTagName, tag does not exist <matthew.garrish@sympatico.ca>
Re: why the perl docs suck <Fred@fred.net>
Re: why the perl docs suck <Fred@fred.net>
Re: why the perl docs suck <Fred@fred.net>
Re: why the perl docs suck <matthew.garrish@sympatico.ca>
Re: why the perl docs suck <Fred@fred.net>
Re: why the perl docs suck <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 11 Oct 2005 20:54:32 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: getElementsByTagName, tag does not exist
Message-Id: <89Z2f.4642$S43.506333@news20.bellglobal.com>
"hymie!" <hymie_@_lactose.homelinux.net> wrote in message
news:BZCdnX_8atGcR9beRVn-uA@comcast.com...
> Greetings. I'm just starting to dabble in XML, and I've run across a
> problem.
>
> I'm going through my XML document using this construct:
>
> use XML::DOM;
> my $parser = new XML::DOM::Parser
> or bail ("Unable to create XML parser");
> my $story = $parser->parse($data);
> $out{"SOURCE"} = $story->getElementsByTagName("Source")->
> item(0)-> getFirstChild->getData;
> $out{"DATE"} = $story->getElementsByTagName("Publication_Date")->
> item(0)-> getFirstChild->getData;
> $out{"TEXT"} = $story->getElementsByTagName("Body_Text")->
> item(0)-> getFirstChild->getData or die "$!";
>
> Everything works fine, until I get to a $story where Body_Text doesn't
> exist. I've looked through all of the XML::DOM docs that I can find,
> but I can't find either a way to test if Body_Text exists, or what happens
> when Body_Text doesn't exist. The script stops with no obvious
> diagnostic output -- it appears that the "die" never happens.
>
It's pretty clear from the docs that getElementsByTagName returns an array
containing all the nodes found, so why don't you just check whether there
are any nodes? As per the documentation:
[untested]
my $nodes = $story->getElementsByTagName('Body_Text');
unless ($nodes->getLength > 0) {
print "Sorry, no nodes!\n"
}
I would recommend XML-Libxml as a better alternative to XML-DOM, though.
Matt
------------------------------
Date: Tue, 11 Oct 2005 21:10:53 -0500
From: "Fred@fred.net" <Fred@fred.net>
Subject: Re: why the perl docs suck
Message-Id: <cerok1le6494j7ng0timchruc2bau839pi@4ax.com>
On Mon, 10 Oct 2005 21:17:51 -0400, "Matt Garrish"
<matthew.garrish@sympatico.ca> wrote:
>
><Fred@fred.net> wrote in message
>news:8qtlk1ls7mt7rn8n1oof5shfus7igkkld9@4ax.com...
>>
>> The "old-timers" and other flame prone morons always love to opine:
>> RTFM
>>
>> Meaning "read the fucking manual".
>>
>> Now, when you hear that from someone, it means they are useless.
>> And you can try and kill file or anything else....
>> (efBi)
>>
>> The reason I post thusly: I was helping a new programmer
>> at work get used to perl. But I had to laugh when we found
>> this gem in the hallowed "docs";
>> looking for info on push() we find this helpful entry in
>> the help files:
>>
>
>I'm still trying to determine what I find most frightening about this post:
>that you were hired as a programmer, that you are teaching someone else or
>that you had to look up the push function and still couldn't understand it.
>
>It's too bad that you've chosen to be a prick than rather contribute
>anything useful. I hope the google archives serve you well...
>
>Matt
>
Not only me. The google archives serve us all.
See how you reveal your ignorance? As if
"that you were hired as a programmer" should be a valid consideration
based on this post.
Your grades were too good at university I suppose.
Example of perl push()
push(@list,$variable);
Where @list is an array and $variable is the next item to be added to
the end of the array.
Period.
------------------------------
Date: Tue, 11 Oct 2005 21:22:27 -0500
From: "Fred@fred.net" <Fred@fred.net>
Subject: Re: why the perl docs suck
Message-Id: <insok11gigfnp2ugdvuv66o4cqit4iq3ih@4ax.com>
On Tue, 11 Oct 2005 10:26:25 +0300, "Veli-Pekka Tätilä"
<vtatila@mail.student.oulu.fi> wrote:
>Fred@fred.net wrote:
>> was helping a new programmer
>> at work get used to perl. <snip>
>> push ARRAY,LIST
>>
>> Treats ARRAY as a stack, and pushes the values of LIST onto the end of
>> ARRAY. The length of ARRAY increases by the length of LIST. Has the
>> same effect as
>>
>> for $value (LIST) {
>> $ARRAY[++$#ARRAY] = $value;
>> }
>> <snip>
>> That's like asking "Hows the weather" and someone begins talking about
>> the big bang theory. It does not even use push.
>Well if it used push to explain push, how would you explain how push works?
>I find the sample code enlightning as it shows you briefly, clearly and
>unambiguously the key idea behind push.
>
>> I don't fucking *want* to think, I wan't a fucking answer right now!
>Could you please mind your Ps and Qs? I reckon not, this doesn't exactly
>give a smart image of you.
>
>> what is the format specifier for printf... let's see it's just like c.
>Ok me too, I wish that perldoc would go into more details here or at least
>reference sprintf more clearly. I think the perldoc page for sprintf gives
>you much more info, however, and prinf mentions that it works like sprintf.
>But no docs are perfect. I like perldocs quite a bit the brief and rather
>formal style somewhat reminds me of the K&R book plus the examples. Have you
>ever browsed the PHP docs? Though the tone is nice and friendly, they often
>leave a lot of behavior unspecified.
>
>> wanted someone to say "It's the percent sign you fucking idiot!!"
>Howabout googling for perl printf example. It's actually faster than ranting
>here.
>
>> Part 1 in a series.
>I think I'll gladly skip the rest, unless you manage to be much more
>objective and give useful feedback.
No docs are perfect, so an admonition to "RTFM" should be given with
more humility than is typical on this NG.
Thanks...
------------------------------
Date: Tue, 11 Oct 2005 21:29:53 -0500
From: "Fred@fred.net" <Fred@fred.net>
Subject: Re: why the perl docs suck
Message-Id: <lrsok11ejmnsarf3k4qqmk338i90st9vga@4ax.com>
On Tue, 11 Oct 2005 09:54:31 +0200, "Bernard El-Hagin"
<bernard.el-haginDODGE_THIS@lido-tech.net> wrote:
>"Fred@fred.net" <Fred@fred.net> wrote:
>
>>
>> The "old-timers" and other flame prone morons always love to
>> opine: RTFM
>
>
>RTFM is not an opinion, it is advice. "I think you should RTFM", on the
>other hand, is an opinion.
>
>
>> Meaning "read the fucking manual".
>> Now, when you hear that from someone, it means they are useless.
>
>
>Who? The person giving the advice, or the person receiving it?
There is no useful advice at that point.
>
>
>> And you can try and kill file or anything else....
>> (efBi)
>
>
>Your grasp of the English language is truly inspiring.
>
>
>> The reason I post thusly: I was helping a new programmer
>> at work get used to perl.
>
>
>You were helping a new programmer get used to the executable? How
>difficult can it be? And why is someone who can't understand a simple
>function like push() helping new programmers?
See they *always* ASSume you don't know what TF your talking about.
Context, context.
>
>
>> But I had to laugh when we found this gem in the hallowed "docs";
>> looking for info on push() we find this helpful entry in
>> the help files:
>>
>> push ARRAY,LIST
>>
>> Treats ARRAY as a stack, and pushes the values of LIST onto the
>> end of ARRAY. The length of ARRAY increases by the length of LIST.
>> Has the same effect as
>>
>> for $value (LIST) {
>> $ARRAY[++$#ARRAY] = $value;
>> }
>>
>> but is more efficient. Returns the new number of elements in the
>> array.
>> That's like asking "Hows the weather" and someone begins talking
>> about the big bang theory.
>
>
>No, it's like asking "How's the weather" and someone begins by talking
>about the...wait for it...yup, weather.
>
>
>> It does not even use push.
>
>
>That's like saying the dictionary definition of "automobile" should be
>"automobile".
Automobile: The noun 'automobile' describes a 4-wheeled motor vehicle;
usually propelled by an internal combustion engine.
>
>
>> I don't fucking *want* to think,
>
>
>Obviously.
>
zzzzzzzzzzzzzz
>
>> I wan't a fucking answer right now!
>
>
>A lobotomy is the answer in your case.
>
>
zzzzzzzzzzzzzz
>> Fucking idots.
>
>
>We agree here. I hate idots even more than I hate icommas. Don't even
>get me started on iquestionmarks and iMacs.
>
>
>> I did not need to be sent off into oblivion by a manual written by
>> idiots.
>
>
>Sadly, manuals don't have that power, whether written by your
>intellectual equals or not.
>
>
zzzzzzzzzzzzzzzzzzzzz
>> I just wanted someone to say "It's the percent sign you
>> fucking idiot!!"
>
>
>Yes, you certainly are.
>
>
>> Right!
>>
>> Part 1 in a series.
>
>
>You are sorely mistaken.
zzzzzzzzzzzzzzzzzzzzzz
------------------------------
Date: Tue, 11 Oct 2005 22:34:05 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: why the perl docs suck
Message-Id: <tC_2f.4791$S43.533607@news20.bellglobal.com>
<Fred@fred.net> wrote in message
news:cerok1le6494j7ng0timchruc2bau839pi@4ax.com...
> On Mon, 10 Oct 2005 21:17:51 -0400, "Matt Garrish"
> <matthew.garrish@sympatico.ca> wrote:
>
>>
>><Fred@fred.net> wrote in message
>>news:8qtlk1ls7mt7rn8n1oof5shfus7igkkld9@4ax.com...
>>>
>>> The "old-timers" and other flame prone morons always love to opine:
>>> RTFM
>>>
>>> Meaning "read the fucking manual".
>>>
>>> Now, when you hear that from someone, it means they are useless.
>>> And you can try and kill file or anything else....
>>> (efBi)
>>>
>>> The reason I post thusly: I was helping a new programmer
>>> at work get used to perl. But I had to laugh when we found
>>> this gem in the hallowed "docs";
>>> looking for info on push() we find this helpful entry in
>>> the help files:
>>>
>>
>>I'm still trying to determine what I find most frightening about this
>>post:
>>that you were hired as a programmer, that you are teaching someone else or
>>that you had to look up the push function and still couldn't understand
>>it.
>>
>>It's too bad that you've chosen to be a prick than rather contribute
>>anything useful. I hope the google archives serve you well...
>
> Not only me. The google archives serve us all.
>
I see simple things go over your head. Since you don't understand the
implication: it'll be your only source of help as your welcome here wore out
long ago.
> See how you reveal your ignorance? As if
> "that you were hired as a programmer" should be a valid consideration
> based on this post.
I wouldn't hire someone who can't look up a simple function and use it. I
wouldn't want someone who can't look up a simple function teaching anyone
else how to program. Had you picked one of the more esoteric commands to
complain about (like someone with pack not too long ago), you might have
found a sympathetic ear. Instead, you chose to rant about a perfectly
obvious and clearly documented function.
I'm happy you think you're getting your revenge on usenet and all the
horrible people who flame you, but I would suggest picking your targets
better in the future.
Matt
------------------------------
Date: Tue, 11 Oct 2005 21:34:07 -0500
From: "Fred@fred.net" <Fred@fred.net>
Subject: Re: why the perl docs suck
Message-Id: <4dtok153of73rer0il3t1g3m2m4qj665kp@4ax.com>
On Tue, 11 Oct 2005 08:39:41 -0500, Tad McClellan
<tadmc@augustmail.com> wrote:
>Fred@fred.net <Fred@fred.net> wrote:
>
>> But I had to laugh when we found
>> this gem in the hallowed "docs";
>> looking for info on push() we find this helpful entry in
>> the help files:
>>
>> push ARRAY,LIST
>>
>> Treats ARRAY as a stack, and pushes the values of LIST onto the end of
>> ARRAY.
>
>
>If you don't know what a stack is, then you should ask what a stack is.
>
>
>> I don't fucking *want*
>
>
>This may come as a shock, but Perl does not exist to please you.
>
>
>> I wan't a fucking answer right now!
>
>
>You will get more responses to your job offer if you mention
>what compensation will be provided.
>
>
>> I did not need to be sent off into oblivion by a manual written by
>> idiots.
>
>
>Then choose some programming language whose manual is not written by idiots.
Well, by God, Tad always weighs in last.
>> I wan't a fucking answer right now!
>
>
>You will get more responses to your job offer if you mention
>what compensation will be provided.
I am still laughing my ass off. I'm crying. That was the funniest
thing I heard the whole day!
Fucking truly hilarious.
------------------------------
Date: Wed, 12 Oct 2005 03:47:31 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: why the perl docs suck
Message-Id: <nH%2f.6864$nz.3634@trnddc03>
Fred@fred.net wrote:
[...]
> Example of perl push()
>
> push(@list,$variable);
> Where @list is an array
Then why do you name the array @list? Do you intent to confuse the reader?
> and $variable is the next item to be added to
> the end of the array.
Which misses the fact that push() takes a list as the second argument....
jue
------------------------------
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 8514
***************************************