[31612] in Perl-Users-Digest
Perl-Users Digest, Issue: 2871 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 12 06:09:36 2010
Date: Fri, 12 Mar 2010 03:09:08 -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 Fri, 12 Mar 2010 Volume: 11 Number: 2871
Today's topics:
Re: Help on String to array ! <hjp-usenet2@hjp.at>
Re: Help on String to array ! <uri@StemSystems.com>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@seesig.invalid
Re: to RG - Lisp lunacy and Perl psychosis <hjp-usenet2@hjp.at>
Re: to RG - Lisp lunacy and Perl psychosis <hjp-usenet2@hjp.at>
Re: to RG - Lisp lunacy and Perl psychosis <john@castleamber.com>
Re: to RG - Lisp lunacy and Perl psychosis <rNOSPAMon@flownet.com>
Re: to RG - Lisp lunacy and Perl psychosis <rNOSPAMon@flownet.com>
Re: Well, that's the most obscure Perl bug I've ever se <KBfoMe@realdomain.net>
Re: Well, that's the most obscure Perl bug I've ever se <hjp-usenet2@hjp.at>
Re: Well, that's the most obscure Perl bug I've ever se <ben@morrow.me.uk>
Re: Well, that's the most obscure Perl bug I've ever se <hjp-usenet2@hjp.at>
Re: Well, that's the most obscure Perl bug I've ever se <devnull4711@web.de>
Re: Well, that's the most obscure Perl bug I've ever se <devnull4711@web.de>
XML::LibXML: Including xml fragments in a larger docume <peter@makholm.net>
Re: XML::LibXML: Including xml fragments in a larger do <peter@makholm.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 Mar 2010 00:31:27 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Help on String to array !
Message-Id: <slrnhpivaf.i4n.hjp-usenet2@hrunkner.hjp.at>
On 2010-03-11 18:30, Uri Guttman <uri@StemSystems.com> wrote:
>>>>>> "JWK" == John W Krahn <someone@example.com> writes:
> anyhow, this whole thing is moot. the OP never said he had a 25GB file
> on a 2gb system.
Right. He never said that. So where did you get that information?
He said he had a 4 MB file and 45 GB of free space (the latter is rather
irrelevant, of course).
hp
------------------------------
Date: Thu, 11 Mar 2010 21:47:06 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Help on String to array !
Message-Id: <876352s1cl.fsf@quad.sysarch.com>
>>>>> "PJH" == Peter J Holzer <hjp-usenet2@hjp.at> writes:
PJH> On 2010-03-11 18:30, Uri Guttman <uri@StemSystems.com> wrote:
>>>>>>> "JWK" == John W Krahn <someone@example.com> writes:
>> anyhow, this whole thing is moot. the OP never said he had a 25GB file
>> on a 2gb system.
PJH> Right. He never said that. So where did you get that information?
PJH> He said he had a 4 MB file and 45 GB of free space (the latter is rather
PJH> irrelevant, of course).
i misread the 45Gb free disk as the file size. he still never mentioned
the file size. as i showed, the unpack is fastest with the data in
ram. i still would want to know his setup (file size included) to see
why his substr would be fastest. it has to be some very odd thing he is
doing and not telling us. there is no way a substr loop could be faster
than a single call to unpack.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 12 Mar 2010 02:13:55 -0600
From: tadmc@seesig.invalid
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
Message-Id: <7oqdnd4n8PNeagTWnZ2dnUVZ_h2dnZ2d@giganews.com>
Outline
Before posting to comp.lang.perl.misc
Must
- Check the Perl Frequently Asked Questions (FAQ)
- Check the other standard Perl docs (*.pod)
Really Really Should
- Lurk for a while before posting
- Search a Usenet archive
If You Like
- Check Other Resources
Posting to comp.lang.perl.misc
Is there a better place to ask your question?
- Question should be about Perl, not about the application area
How to participate (post) in the clpmisc community
- Carefully choose the contents of your Subject header
- Use an effective followup style
- Speak Perl rather than English, when possible
- Ask perl to help you
- Do not re-type Perl code
- Provide enough information
- Do not provide too much information
- Do not post binaries, HTML, or MIME
Social faux pas to avoid
- Asking a Frequently Asked Question
- Asking a question easily answered by a cursory doc search
- Asking for emailed answers
- Beware of saying "doesn't work"
- Sending a "stealth" Cc copy
Be extra cautious when you get upset
- Count to ten before composing a followup when you are upset
- Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------
Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
This newsgroup, commonly called clpmisc, is a technical newsgroup
intended to be used for discussion of Perl related issues (except job
postings), whether it be comments or questions.
As you would expect, clpmisc discussions are usually very technical in
nature and there are conventions for conduct in technical newsgroups
going somewhat beyond those in non-technical newsgroups.
The article at:
http://www.catb.org/~esr/faqs/smart-questions.html
describes how to get answers from technical people in general.
This article describes things that you should, and should not, do to
increase your chances of getting an answer to your Perl question. It is
available in POD, HTML and plain text formats at:
http://www.rehabitation.com/clpmisc.shtml
For more information about netiquette in general, see the "Netiquette
Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
A note to newsgroup "regulars":
Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume that they do
know and are being the "bad kind" of Lazy.
A note about technical terms used here:
In this document, we use words like "must" and "should" as
they're used in technical conversation (such as you will
encounter in this newsgroup). When we say that you *must* do
something, we mean that if you don't do that something, then
it's unlikely that you will benefit much from this group.
We're not bossing you around; we're making the point without
lots of words.
Do *NOT* send email to the maintainer of these guidelines. It will be
discarded unread. The guidelines belong to the newsgroup so all
discussion should appear in the newsgroup. I am just the secretary that
writes down the consensus of the group.
Before posting to comp.lang.perl.misc
Must
This section describes things that you *must* do before posting to
clpmisc, in order to maximize your chances of getting meaningful replies
to your inquiry and to avoid getting flamed for being lazy and trying to
have others do your work.
The perl distribution includes documentation that is copied to your hard
drive when you install perl. Also installed is a program for looking
things up in that (and other) documentation named 'perldoc'.
You should either find out where the docs got installed on your system,
or use perldoc to find them for you. Type "perldoc perldoc" to learn how
to use perldoc itself. Type "perldoc perl" to start reading Perl's
standard documentation.
Check the Perl Frequently Asked Questions (FAQ)
Checking the FAQ before posting is required in Big 8 newsgroups in
general, there is nothing clpmisc-specific about this requirement.
You are expected to do this in nearly all newsgroups.
You can use the "-q" switch with perldoc to do a word search of the
questions in the Perl FAQs.
Check the other standard Perl docs (*.pod)
The perl distribution comes with much more documentation than is
available for most other newsgroups, so in clpmisc you should also
see if you can find an answer in the other (non-FAQ) standard docs
before posting.
It is *not* required, or even expected, that you actually *read* all of
Perl's standard docs, only that you spend a few minutes searching them
before posting.
Try doing a word-search in the standard docs for some words/phrases
taken from your problem statement or from your very carefully worded
"Subject:" header.
Really Really Should
This section describes things that you *really should* do before posting
to clpmisc.
Lurk for a while before posting
This is very important and expected in all newsgroups. Lurking means
to monitor a newsgroup for a period to become familiar with local
customs. Each newsgroup has specific customs and rituals. Knowing
these before you participate will help avoid embarrassing social
situations. Consider yourself to be a foreigner at first!
Search a Usenet archive
There are tens of thousands of Perl programmers. It is very likely
that your question has already been asked (and answered). See if you
can find where it has already been answered.
One such searchable archive is:
http://groups.google.com/advanced_search
If You Like
This section describes things that you *can* do before posting to
clpmisc.
Check Other Resources
You may want to check in books or on web sites to see if you can
find the answer to your question.
But you need to consider the source of such information: there are a
lot of very poor Perl books and web sites, and several good ones
too, of course.
Posting to comp.lang.perl.misc
There can be 200 messages in clpmisc in a single day. Nobody is going to
read every article. They must decide somehow which articles they are
going to read, and which they will skip.
Your post is in competition with 199 other posts. You need to "win"
before a person who can help you will even read your question.
These sections describe how you can help keep your article from being
one of the "skipped" ones.
Is there a better place to ask your question?
Question should be about Perl, not about the application area
It can be difficult to separate out where your problem really is,
but you should make a conscious effort to post to the most
applicable newsgroup. That is, after all, where you are the most
likely to find the people who know how to answer your question.
Being able to "partition" a problem is an essential skill for
effectively troubleshooting programming problems. If you don't get
that right, you end up looking for answers in the wrong places.
It should be understood that you may not know that the root of your
problem is not Perl-related (the two most frequent ones are CGI and
Operating System related), so off-topic postings will happen from
time to time. Be gracious when someone helps you find a better place
to ask your question by pointing you to a more applicable newsgroup.
How to participate (post) in the clpmisc community
Carefully choose the contents of your Subject header
You have 40 precious characters of Subject to win out and be one of
the posts that gets read. Don't waste them. Take care while
composing them, they are the key that opens the door to getting an
answer.
Spend them indicating what aspect of Perl others will find if they
should decide to read your article.
Do not spend them indicating "experience level" (guru, newbie...).
Do not spend them pleading (please read, urgent, help!...).
Do not spend them on non-Subjects (Perl question, one-word
Subject...)
For more information on choosing a Subject see "Choosing Good
Subject Lines":
http://www.cpan.org/authors/id/D/DM/DMR/subjects.post
Part of the beauty of newsgroup dynamics, is that you can contribute
to the community with your very first post! If your choice of
Subject leads a fellow Perler to find the thread you are starting,
then even asking a question helps us all.
Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Always indicate who
wrote the quoted material. Never quote an entire article. Never
quote a .signature (unless that is what you are commenting on).
Intersperse your comments *following* each section of quoted text to
which they relate. Unappreciated followup styles are referred to as
"top-posting", "Jeopardy" (because the answer comes before the
question), or "TOFU" (Text Over, Fullquote Under).
Reversing the chronology of the dialog makes it much harder to
understand (some folks won't even read it if written in that style).
For more information on quoting style, see:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
Speak Perl rather than English, when possible
Perl is much more precise than natural language. Saying it in Perl
instead will avoid misunderstanding your question or problem.
Do not say: I have variable with "foo\tbar" in it.
Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
or I have $var = <DATA> (and show the data line).
Ask perl to help you
You can ask perl itself to help you find common programming mistakes
by doing two things: enable warnings (perldoc warnings) and enable
"strict"ures (perldoc strict).
You should not bother the hundreds/thousands of readers of the
newsgroup without first seeing if a machine can help you find your
problem. It is demeaning to be asked to do the work of a machine. It
will annoy the readers of your article.
You can look up any of the messages that perl might issue to find
out what the message means and how to resolve the potential mistake
(perldoc perldiag). If you would like perl to look them up for you,
you can put "use diagnostics;" near the top of your program.
Do not re-type Perl code
Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.
Provide enough information
If you do the things in this item, you will have an Extremely Good
chance of getting people to try and help you with your problem!
These features are a really big bonus toward your question winning
out over all of the other posts that you are competing with.
First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)
Describe *precisely* the input to your program. Also provide example
input data for your program. If you need to show file input, use the
__DATA__ token (perldata.pod) to provide the file contents inside of
your Perl program.
Show the output (including the verbatim text of any messages) of
your program.
Describe how you want the output to be different from what you are
getting.
If you have no idea at all of how to code up your situation, be sure
to at least describe the 2 things that you *do* know: input and
desired output.
Do not provide too much information
Do not just post your entire program for debugging. Most especially
do not post someone *else's* entire program.
Do not post binaries, HTML, or MIME
clpmisc is a text only newsgroup. If you have images or binaries
that explain your question, put them in a publically accessible
place (like a Web server) and provide a pointer to that location. If
you include code, cut and paste it directly in the message body.
Don't attach anything to the message. Don't post vcards or HTML.
Many people (and even some Usenet servers) will automatically filter
out such messages. Many people will not be able to easily read your
post. Plain text is something everyone can read.
Social faux pas to avoid
The first two below are symptoms of lots of FAQ asking here in clpmisc.
It happens so often that folks will assume that it is happening yet
again. If you have looked but not found, or found but didn't understand
the docs, say so in your article.
Asking a Frequently Asked Question
It should be understood that you may have missed the applicable FAQ
when you checked, which is not a big deal. But if the Frequently
Asked Question is worded similar to your question, folks will assume
that you did not look at all. Don't become indignant at pointers to
the FAQ, particularly if it solves your problem.
Asking a question easily answered by a cursory doc search
If folks think you have not even tried the obvious step of reading
the docs applicable to your problem, they are likely to become
annoyed.
If you are flamed for not checking when you *did* check, then just
shrug it off (and take the answer that you got).
Asking for emailed answers
Emailed answers benefit one person. Posted answers benefit the
entire community. If folks can take the time to answer your
question, then you can take the time to go get the answer in the
same place where you asked the question.
It is OK to ask for a *copy* of the answer to be emailed, but many
will ignore such requests anyway. If you munge your address, you
should never expect (or ask) to get email in response to a Usenet
post.
Ask the question here, get the answer here (maybe).
Beware of saying "doesn't work"
This is a "red flag" phrase. If you find yourself writing that,
pause and see if you can't describe what is not working without
saying "doesn't work". That is, describe how it is not what you
want.
Sending a "stealth" Cc copy
A "stealth Cc" is when you both email and post a reply without
indicating *in the body* that you are doing so.
Be extra cautious when you get upset
Count to ten before composing a followup when you are upset
This is recommended in all Usenet newsgroups. Here in clpmisc, most
flaming sub-threads are not about any feature of Perl at all! They
are most often for what was seen as a breach of netiquette. If you
have lurked for a bit, then you will know what is expected and won't
make such posts in the first place.
But if you get upset, wait a while before writing your followup. I
recommend waiting at least 30 minutes.
Count to ten after composing and before posting when you are upset
After you have written your followup, wait *another* 30 minutes
before committing yourself by posting it. You cannot take it back
once it has been said.
AUTHOR
Tad McClellan and many others on the comp.lang.perl.misc newsgroup.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Fri, 12 Mar 2010 00:06:37 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: to RG - Lisp lunacy and Perl psychosis
Message-Id: <slrnhpitru.i4n.hjp-usenet2@hrunkner.hjp.at>
On 2010-03-10 20:54, John Bokma <john@castleamber.com> wrote:
> Jürgen Exner <jurgenex@hotmail.com> writes:
>> ccc31807 <cartercc@gmail.com> wrote:
>>>On Mar 10, 1:48 pm, Jürgen Exner <jurge...@hotmail.com> wrote:
>>>> That code is abominable and obfuscated, but of course you can write
>>>> abominable and obfuscated code in any programming language.
>> [...]
>>>$fac{$sec{$key}{'id1'}}{'location'}
>>
>> Thank you for confirming my point.
>>
>>>This isn't harder than C pointers.
>>
>> Saying something isn't harder than C pointers is like saying a desease
>> isn't worse than the Bubonic plague: it gives very little comfort to
>> people suffering from it.
>> Actually C pointers are probably among the worst concepts ever invented
>> in computer science.
>
> They are not "invented" they are somewhat a 1:1 mapping to
> assembly. I've never had problems with C pointers but that's most likely
> also because I had programmed in Z80 assembly [1] (and some motorola
> processors) for a few years before programming in C.
I started with BASIC (think early 1980's here - line numbers and goto),
then did a little bit of Pascal and assembly (6502 and Z80) before
learning C. Seeing the similarities between assembly and C has been a
real eye opener for me - suddenly I understood Pascal pointers (which
even more restrictive than Perl references).
> I do agree, however, that it would've been nice if C had references like
> Perl, and (harder to get to) pointers as they are now.
Actually, C pointers are quite ok in theory (for example, you can't make
a pointer into an array point outside of the array (except "just after"
it). The problem is that (almost) all C compilers omit the necessary
run-time checks for performance reasons and because of binary
compatibility constraints (you would need "fat pointers" to implement
them).
> That, and a better standard library.
Yup. That one is very haphazard and seriously dated.
> Disclaimer: haven't programmed in C for a while.
Me, too.
hp
------------------------------
Date: Fri, 12 Mar 2010 00:18:45 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: to RG - Lisp lunacy and Perl psychosis
Message-Id: <slrnhpiuin.i4n.hjp-usenet2@hrunkner.hjp.at>
On 2010-03-10 21:22, Jürgen Exner <jurgenex@hotmail.com> wrote:
> John Bokma <john@castleamber.com> wrote:
>>Jürgen Exner <jurgenex@hotmail.com> writes:
>>> ccc31807 <cartercc@gmail.com> wrote:
>>>>This isn't harder than C pointers.
>>>
>>> Saying something isn't harder than C pointers is like saying a desease
>>> isn't worse than the Bubonic plague: it gives very little comfort to
>>> people suffering from it.
>>> Actually C pointers are probably among the worst concepts ever invented
>>> in computer science.
>>
>>They are not "invented" they are somewhat a 1:1 mapping to
>>assembly.
>
> Exactly. You can hardly do worse than that ;-)
>
> But in all fairness, when C was developed in the early 70s it was a
> major step forward and Kerningham and Ritchie could not possibly have
> known as much as we do today.
That and they had to fit the compiler into 64k of memory. And it had to
finish in a reasonable time on a PDP-11. That somewhat limits what you
can do even if you know how to write a better language in theory.
(I do remember the MFII COBOL compiler on an 8086 - compiling our
program took half an hour)
> For its time it was a great concept and
> implementation. It's just that it is way outdated 40 years later.
Yup.
>>I do agree, however, that it would've been nice if C had references like
>>Perl, and (harder to get to) pointers as they are now.
>
> Or even Pascal or Modula or Haskell or pick pretty much any more modern
> language.
Pascal is older than C. And its pointers are (were?) particularly useless.
Modula-2 was actually quite nice. One can see that Wirth used it to
write real code and not just for teaching :-).
hp
------------------------------
Date: Thu, 11 Mar 2010 20:14:20 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: to RG - Lisp lunacy and Perl psychosis
Message-Id: <87tysm8ewz.fsf@castleamber.com>
"Peter J. Holzer" <hjp-usenet2@hjp.at> writes:
> On 2010-03-10 20:54, John Bokma <john@castleamber.com> wrote:
[..]
> I started with BASIC (think early 1980's here - line numbers and
> goto),
ZX Spectrum, 1983 here
> then did a little bit of Pascal and assembly (6502 and Z80) before
More or less same here, Z80, Comal, Pascal, 6800, 6809, 68000 ...
>> I do agree, however, that it would've been nice if C had references like
>> Perl, and (harder to get to) pointers as they are now.
>
> Actually, C pointers are quite ok in theory (for example, you can't make
> a pointer into an array point outside of the array (except "just after"
> it).
How does C prevent this? Or I don't understand what a pointer into an
array is.
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
Date: Thu, 11 Mar 2010 21:04:32 -0800
From: Ron Garret <rNOSPAMon@flownet.com>
Subject: Re: to RG - Lisp lunacy and Perl psychosis
Message-Id: <rNOSPAMon-587A9E.21043211032010@news.albasani.net>
In article <slrnhpisqf.i4n.hjp-usenet2@hrunkner.hjp.at>,
"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
> In any case I very much doubt that it is much easier to find the bug in
> a lisp program which "suddenly started failing silently and
> intermittently" than in a Perl program which does the same.
I assure you, you are quite mistaken. I have a first-hand data point on
that as well:
http://ti.arc.nasa.gov/m/pub/archive/2000-0176.pdf
rg
------------------------------
Date: Thu, 11 Mar 2010 21:45:38 -0800
From: Ron Garret <rNOSPAMon@flownet.com>
Subject: Re: to RG - Lisp lunacy and Perl psychosis
Message-Id: <rNOSPAMon-54D5B1.21453811032010@news.albasani.net>
In article <732o67-cj6.ln1@news.rtij.nl>,
Martijn Lievaart <m@rtij.nl.invlalid> wrote:
> On Wed, 10 Mar 2010 16:41:27 -0800, Ron Garret wrote:
>
> > Why must those be the only possibilities? It was because the Perl code,
> > which had been working fine for months, suddenly started failing
> > silently and intermittently, and I was told there was no way to do the
> > equivalent of wrapping the whole script in the equivalent of a
> > TRY...EXCEPT form in order to catch the error. Whether this was in fact
> > true or whether the entire engineering team was incompetent I do not
> > know. But they seemed pretty bright and capable otherwise, so it would
> > be pretty odd for them all to be mistaken about this.
>
> If they didn't know about eval { original code here };, they were
> incompetent. But there were probably other factors at work you didn't
> tell about.
I'm sure there were. But it's not that I'm holding out on you, it's
that I never fully understood the details even at the time.
rg
------------------------------
Date: Thu, 11 Mar 2010 17:17:07 -0600
From: "Kyle T. Jones" <KBfoMe@realdomain.net>
Subject: Re: Well, that's the most obscure Perl bug I've ever seen
Message-Id: <hnbtll$n6t$1@news.eternal-september.org>
I guess instead of a snark, I could have offered this (it's ugly,
there's undoubtedly an easier way to do it, I invite criticism, but I'm
95% it'll work just fine):
#!/usr/bin/perl;
use strict;
use warnings;
sub appendtotop{
my ($olddir, $newdir, $filename)=@_;
my $oldfile=$olddir.$filename;
my $newfile=$newdir.$filename;
open(OLDPERL, $oldfile) || die "cannot open file $oldfile";
open(NEWPERL, ">$newfile")|| die "cannot open file $newfile";
my @contents=<OLDPERL>;
my ($isstrict, $iswarned)=(0,0);
#this looks kind of odd because I'm only checking the first ten
#lines to make sure we don't have duplicate use whatevers
#but it's more because you mentioned that you were dropping
#use strict and use warnings in blocks later on in the code
for (my $i=0; $i<10; $i++){
if($contents[$i]){
$isstrict=1 if($contents[$i]=~/use strict;/);
$iswarned=1 if($contents[$i]=~/use warnings;/);
}
}
my @appendmaterial;
$appendmaterial[0]="use strict;\n" unless($isstrict==1);
$appendmaterial[1]="use warnings;\n" unless($iswarned==1);
print NEWPERL @appendmaterial;
print NEWPERL @contents;
return;
}
my $currentperlscripts='/var/www/cgi-bin/';
my $newdirectory='/var/www/new-cgi-bin/';
opendir(OLD,$currentperlscripts) || die "Cannot opendir
$currentperlscripts: $!";
my @files=readdir(OLD);
foreach (@files){
if($_=~/\.pl/){
appendtotop($currentperlscripts, $newdirectory, $_);
}
}
------------------------------
Date: Fri, 12 Mar 2010 00:25:12 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Well, that's the most obscure Perl bug I've ever seen
Message-Id: <slrnhpiuup.i4n.hjp-usenet2@hrunkner.hjp.at>
On 2010-03-11 19:14, Ben Morrow <ben@morrow.me.uk> wrote:
>
> Quoth Frank Seitz <devnull4711@web.de>:
>> Uri Guttman wrote:
>> >>>>>> "FS" == Frank Seitz <devnull4711@web.de> writes:
>> >
>> > FS> Yes, this is what I meant. The conversion makes sense because
>> > FS> a reference is basically a memory address (plus type),
>> > FS> and a memory address is an integer.
>> >
>> > to be clear, a ref will return a number (the address) in a numeric
>> > context or the TYPE(0xfdddd) style in a string context. it is not a
>> > number but a multivalued thing that returns different things in
>> > different contexts. it is a ref, number AND string all in the same
>> > scalar if you want to see it that way. but once you modify it with ++ it
>> > becomes only a number thereafter.
>>
>> Very good explanation, except that I would not say that
>> a reference "returns" something, because it is a (passive) data structure.
>
> There's no such thing in Perl. Evaluating a ref in numeric context
> numifies it. It's the same as
>
> float a;
> int b = 3;
> a = b;
>
> in C, which is actually an implicit function call
There is no implicit function call here. Did you mean an implicit cast?
> (though Perl caches the result, which C doesn't).
Well, the result is stored in a. So it is "cached" in some sense.
And the compiler is of course free to cache the value of any expression
somewhere in a temporary variable if it thinks it can reuse it. So in some
code like:
x = a + b * c + d;
y = a + b * c;
a C compiler probably will "cache" the result of "a + b * c", while the
perl compiler won't.
hp
------------------------------
Date: Fri, 12 Mar 2010 00:01:28 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Well, that's the most obscure Perl bug I've ever seen
Message-Id: <orco67-rip1.ln1@osiris.mauzo.dyndns.org>
Quoth "Peter J. Holzer" <hjp-usenet2@hjp.at>:
> On 2010-03-11 19:14, Ben Morrow <ben@morrow.me.uk> wrote:
> >
> > There's no such thing in Perl. Evaluating a ref in numeric context
> > numifies it. It's the same as
> >
> > float a;
> > int b = 3;
> > a = b;
> >
> > in C, which is actually an implicit function call
>
> There is no implicit function call here. Did you mean an implicit cast?
I phrased that badly: there is no C function call. But there is an
operation more complicated than simple assignment, such as might result
from the inlining of a function that does the conversion.
I was avoiding the term 'cast' because it means two different things in
C. Sometimes it means an actual conversion from one representation to
another, sometimes it means simply reinterpreting the existing bits as a
different type (casts between pointers to compatible structures, for
instance).
> > (though Perl caches the result, which C doesn't).
>
> Well, the result is stored in a. So it is "cached" in some sense.
> And the compiler is of course free to cache the value of any expression
> somewhere in a temporary variable if it thinks it can reuse it. So in some
> code like:
>
> x = a + b * c + d;
> y = a + b * c;
>
> a C compiler probably will "cache" the result of "a + b * c", while the
> perl compiler won't.
That's true, of course. OTOH, if you have
void bar(int x)
{
float f = x;
}
void foo()
{
int a = 1;
float b = a;
bar(a);
}
it won't, unless it can inline bar to assist the optimization, whereas
perl would.
Ben
------------------------------
Date: Fri, 12 Mar 2010 01:07:32 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Well, that's the most obscure Perl bug I've ever seen
Message-Id: <slrnhpj1e4.d4p.hjp-usenet2@hrunkner.hjp.at>
On 2010-03-11 23:17, Kyle T. Jones <KBfoMe@realdomain.net> wrote:
> I guess instead of a snark, I could have offered this (it's ugly,
> there's undoubtedly an easier way to do it, I invite criticism, but I'm
> 95% it'll work just fine):
>
[script snipped]
I seem to be missing the part of the script which fixes all the errors
and warnings ...
hp
------------------------------
Date: Fri, 12 Mar 2010 10:32:18 +0100
From: Frank Seitz <devnull4711@web.de>
Subject: Re: Well, that's the most obscure Perl bug I've ever seen
Message-Id: <7vug12F5uhU1@mid.individual.net>
Ben Morrow wrote:
> Quoth Frank Seitz <devnull4711@web.de>:
>> Uri Guttman wrote:
>>>
>>> to be clear, a ref will return a number (the address) in a numeric
>>> context or the TYPE(0xfdddd) style in a string context. it is not a
>>> number but a multivalued thing that returns different things in
>>> different contexts. it is a ref, number AND string all in the same
>>> scalar if you want to see it that way. but once you modify it with ++ it
>>> becomes only a number thereafter.
>>
>> Very good explanation, except that I would not say that
>> a reference "returns" something, because it is a (passive) data structure.
>
> There's no such thing in Perl.
Hm. Perl has no data structures?
> Evaluating a ref in numeric context numifies it.
Yes. But it is perl that interprets and converts the
the scalar (= data structure), not the scalar itself.
> It's the same as
>
> float a;
> int b = 3;
> a = b;
>
> in C, which is actually an implicit function call (though Perl caches
> the result, which C doesn't).
Would you say about line 3: b "returns" a float?
Frank
--
Dipl.-Inform. Frank Seitz
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
Blog: http://www.fseitz.de/blog
XING-Profil: http://www.xing.com/profile/Frank_Seitz2
------------------------------
Date: Fri, 12 Mar 2010 10:35:54 +0100
From: Frank Seitz <devnull4711@web.de>
Subject: Re: Well, that's the most obscure Perl bug I've ever seen
Message-Id: <7vug7qF5uhU2@mid.individual.net>
Uri Guttman wrote:
>>>>>> "FS" == Frank Seitz <devnull4711@web.de> writes:
>
> FS> Very good explanation, except that I would not say that
> FS> a reference "returns" something, because it is a (passive) data structure.
>
> hard to find a better word for what a value is in different
> contexts. returns seems to work even though it isn't a sub. you can say
> the same for a sub that checks wantarray or other things that 'return'
> different values in different contexts (e.g. arrays). how would you say
> this?
I would say, the reference is "evaluated" or "interpreted"
depending on the context.
> arrays return their size in scalar context and a list of their elements
> in list context.
Paraphrase: Arrays evaluate to their size in scalar context and to a list
of their elements in list context. (?)
Frank
--
Dipl.-Inform. Frank Seitz
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
Blog: http://www.fseitz.de/blog
XING-Profil: http://www.xing.com/profile/Frank_Seitz2
------------------------------
Date: Fri, 12 Mar 2010 11:07:40 +0100
From: Peter Makholm <peter@makholm.net>
Subject: XML::LibXML: Including xml fragments in a larger document
Message-Id: <87sk854zv7.fsf@vps1.hacking.dk>
For a project I receive some XML fragments from a data base and have
to include it in a larger XML document created with XML::LibXML. With
version 1.66 of XML::LibXML I was able to to something like
my $doc = XML::LibXML::Document->new('1.0', 'utf-8' );
my $root = $doc->createElement("X:root");
$doc->setDocumentElement($root);
my $node = XML::LibXML->new()->parse_balanced_chunk(
'<owner>peter@makholm.net</owner>'
);
$doc->adoptNode($node);
$root->addChild($node);
But with version 1.70 of XML::LibXML this fails with an error saying
'Adding document fragments with addChild not supported!'
Is there a working way to implement this?
//Makholm
------------------------------
Date: Fri, 12 Mar 2010 11:38:26 +0100
From: Peter Makholm <peter@makholm.net>
Subject: Re: XML::LibXML: Including xml fragments in a larger document
Message-Id: <87ocit4yfx.fsf@vps1.hacking.dk>
Peter Makholm <peter@makholm.net> writes:
> my $node = XML::LibXML->new()->parse_balanced_chunk(
> '<owner>peter@makholm.net</owner>'
> );
> $doc->adoptNode($node);
> $root->addChild($node);
After a bit more trying I can up with this solution:
my $fragment = XML::LibXML->new()->parse_balanced_chunk(
'<owner>peter@makholm.net</owner>'
);
for my $node ($fragment->childNodes) {
$root->addChild($node);
}
It works in both XML::LibXML version 1.66 and 1.70.
//Makholm
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 2871
***************************************