[31861] in Perl-Users-Digest
Perl-Users Digest, Issue: 3124 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 7 21:09:24 2010
Date: Tue, 7 Sep 2010 18:09:07 -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, 7 Sep 2010 Volume: 11 Number: 3124
Today's topics:
Re: ActiveState Perl 5.10 on Windows XP - can't shell!! <perljunkie@gmail.com>
Re: convert byte stream to integers <ben@morrow.me.uk>
Re: convert byte stream to integers <toralf.foerster@gmx.de>
Re: convert byte stream to integers <smallpond@juno.com>
Re: convert byte stream to integers <uri@StemSystems.com>
Re: convert byte stream to integers <ben@morrow.me.uk>
Re: Ideal data structure for nested list format? <sherm.pendley@gmail.com>
Re: Ideal data structure for nested list format? <sherm.pendley@gmail.com>
Re: Ideal data structure for nested list format? <tuxedo@mailinator.com>
Re: Ideal data structure for nested list format? <ben@morrow.me.uk>
Re: slices <jwkrahn@example.com>
Re: slices <mvdwege@mail.com>
Re: slices <tadmc@seesig.invalid>
XML Xpath interrogation <larrysulky@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 7 Sep 2010 13:11:15 -0700 (PDT)
From: Perl Junkie <perljunkie@gmail.com>
Subject: Re: ActiveState Perl 5.10 on Windows XP - can't shell!!??
Message-Id: <c239a82c-e83b-4581-8510-87d07e09558d@y11g2000yqm.googlegroups.com>
On Sep 1, 3:58=A0am, Wolf Behrenhoff
<NoSpamPleaseButThisIsVal...@gmx.net> wrote:
> On 31.08.2010 00:20, Ben Morrow wrote:
>
>
>
> > Quoth Perl Junkie <perljun...@gmail.com>:
> >> On Aug 30, 3:22 pm, Ben Morrow <b...@morrow.me.uk> wrote:
>
> >>> Do you have either COMSPEC or PERL5SHELL set to something weird in th=
e
> >>> environment? Are you attempting to do any of this from a non-standard
> >>> terminal emulator (such as 4NT)?
>
> > I presume since you didn't answer that these are all 'no's?
>
> I agree, this is an important question.
>
> >>> What do you get if you run
>
> >>> perl -le "system 'dir'; print ":$?:${^CHILD_ERROR_NATIVE}:$!:$^E:"
FYI, I re-quoted this with qq{} first before running. Yes, as it was
originally submitted, it had quoting issues.
>
> >> Result is:
>
> >> :65280:65280:No such file or directory:The filename or extension is
> >> too long:
>
> > Something else you could try: can you start processes with
> > Win32::Process? That's a good deal closer to CreateProcess(3), so it
> > might give us some idea of where the problem is. (It also might give an
> > accurate error indication that hasn't been stomped on by some other
> > code.)
>
> Hm... indeed very strange. As Ben mentioned CreateProcess, another idea
> came to my mind. Is a "Personal Firewall" installed on your machine or
> any other "security" software? If yes, that could be the cause for these
> problems.
No firewalls or anything. I'm over here doing the same thing --
thinking something was installed on my machine... a patch? ...a new
GPO? ...a new setting in McAfee? I mean, it just STOPPED WORKING and
it makes NO SENSE.
The Win32::Process idea is a good idea. I'll try that. Otherwise, I
may have to actually reimage my machine over this. Another notch in
my "Why I hate Windows" belt...
-pj
------------------------------
Date: Tue, 7 Sep 2010 16:21:19 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: convert byte stream to integers
Message-Id: <fs1il7-lf92.ln1@osiris.mauzo.dyndns.org>
Quoth Toralf =?UTF-8?B?RsO2cnN0ZXI=?= <toralf.foerster@gmx.de>:
> Reading this article
> http://mpl.mpg.de/mpf/php/abteilung1/index.php?lang=de&show=workgroups&in=qiv&and=&page=qiv/quantumbits
> I'm wondering how can a readin from this file
> http://mpl.mpg.de/mpf/php/abteilung1/template/qiv/200MiB/cohnopafinal_0.65_sha512_portion04
> with a perl program - eg. 32bit integers
perldoc -f unpack
(and perldoc -f pack for the actual format specifiers).
Ben
------------------------------
Date: Tue, 07 Sep 2010 17:46:54 +0200
From: Toralf =?UTF-8?B?RsO2cnN0ZXI=?= <toralf.foerster@gmx.de>
Subject: Re: convert byte stream to integers
Message-Id: <i65mpe$k9u$1@news.eternal-september.org>
Ben Morrow wrote:
> perldoc -f unpack
Yep, RTFM b/c I made the wrong question, ok again :
I'm unsure how do I read the 2nd 4byte integer in :
tfoerste@n22 ~/download $ dd if=cohnopafinal_0.65_sha512_portion04 of=4byte
bs=4 count=2
2+0 records in
2+0 records out
8 bytes (8 B) copied, 0.000438815 s, 18.2 kB/s
because this gives only the answer for the first 4 bytes :
tfoerste@n22 ~/download $ cat 4byte | perl -wane 'print unpack "N", $_;
print "\n"'
1831393600
--
MfG/Sincerely
Toralf Förster
pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6 9DA3
------------------------------
Date: Tue, 07 Sep 2010 12:13:42 -0400
From: Steve C <smallpond@juno.com>
Subject: Re: convert byte stream to integers
Message-Id: <i65obr$cmg$1@news.eternal-september.org>
On 09/07/2010 11:03 AM, Toralf Förster wrote:
> Reading this article
> http://mpl.mpg.de/mpf/php/abteilung1/index.php?lang=de&show=workgroups&in=qiv&and=&page=qiv/quantumbits
> I'm wondering how can a readin from this file
> http://mpl.mpg.de/mpf/php/abteilung1/template/qiv/200MiB/cohnopafinal_0.65_sha512_portion04
> with a perl program - eg. 32bit integers
>
much like with any other language (perl functions in parens)
1) open the file (open)
2) loop through until end-of-file (while, eof)
3) read 32 bits from the file (read)
4) store the data in a variable (unpack)
5) process it - your code here
6) when done close the file (close)
The unpack might seem non-obvious. It takes a string and unpacks it as a perl value.
The reason this step is separate from the read is that perl variables have to know
what type of data they contain, since they can hold different types.
------------------------------
Date: Tue, 07 Sep 2010 12:18:52 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: convert byte stream to integers
Message-Id: <87vd6h34sz.fsf@quad.sysarch.com>
>>>>> "TF" == Toralf Förster <toralf.foerster@gmx.de> writes:
TF> Ben Morrow wrote:
>> perldoc -f unpack
TF> Yep, RTFM b/c I made the wrong question, ok again :
TF> I'm unsure how do I read the 2nd 4byte integer in :
TF> tfoerste@n22 ~/download $ dd if=cohnopafinal_0.65_sha512_portion04 of=4byte
TF> bs=4 count=2
TF> 2+0 records in
TF> 2+0 records out
TF> 8 bytes (8 B) copied, 0.000438815 s, 18.2 kB/s
TF> because this gives only the answer for the first 4 bytes :
TF> tfoerste@n22 ~/download $ cat 4byte | perl -wane 'print unpack "N", $_;
TF> print "\n"'
TF> 1831393600
ever heard of a loop or a quantifier? N only converts one word so why
would you think it would 2 words? there is also a perlpacktut doc you
should read. pack/unpack have lots of formats and options to handle most
any binary data out there. and if you can't do it in one call, you can
use perl to grab data for use by pack/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: Tue, 7 Sep 2010 19:22:16 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: convert byte stream to integers
Message-Id: <ofcil7-o8b2.ln1@osiris.mauzo.dyndns.org>
Quoth Toralf =?UTF-8?B?RsO2cnN0ZXI=?= <toralf.foerster@gmx.de>:
> Ben Morrow wrote:
> > perldoc -f unpack
>
> Yep, RTFM b/c I made the wrong question, ok again :
>
> I'm unsure how do I read the 2nd 4byte integer in :
>
> tfoerste@n22 ~/download $ dd if=cohnopafinal_0.65_sha512_portion04 of=4byte
> bs=4 count=2
> 2+0 records in
> 2+0 records out
> 8 bytes (8 B) copied, 0.000438815 s, 18.2 kB/s
>
> because this gives only the answer for the first 4 bytes :
>
> tfoerste@n22 ~/download $ cat 4byte | perl -wane 'print unpack "N", $_;
> print "\n"'
> 1831393600
[You don't need -a there, since you're not using @F.]
That depends on what exactly you want. If you just want the second
4-byte integer, unpack "x4N" will give it to you. If you want to unpack
the whole stream into integers, unpack "N*" will return them as a list.
pack and unpack are powerful but subtle. Getting them to do what you
want can take quite a bit of poring over the format specs in perldoc -f
pack. If you haven't already, you probably want to read perldoc
perlpacktut.
Ben
------------------------------
Date: Tue, 07 Sep 2010 11:54:13 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Ideal data structure for nested list format?
Message-Id: <m2k4mxwnve.fsf@sherm.shermpendley.com>
Tuxedo <tuxedo@mailinator.com> writes:
> If it was as simple as to pin-point one specific part I would have asked
> that more specific question. As in most programs, the individual parts are
> generally glued together in complex ways that can make it difficult to see
> any one part clearly without understanding most of it to begin with.
Then break it down. Step away from the complex program that is your
long-term goal, and work on smaller ones that help illustrate the one
part you need to see more clearly.
> However, the job needs to be done and there isn't enough time
That's a *very* poor occasion on which to attempt a learning exercise.
When deadlines are tight and looming, stick with the tools you know.
> I did a quick search and found it odd I could not find a single template or
> module that does the job of generating nested ul's and li's specifically,
> considering how complex it can be to build such procedures from scratch.
The example I gave took about ten minutes to write, from start to
finish. You're not going to find modules for such trivial tasks.
sherm--
--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
------------------------------
Date: Tue, 07 Sep 2010 11:59:05 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Ideal data structure for nested list format?
Message-Id: <m2fwxlwnna.fsf@sherm.shermpendley.com>
Tuxedo <tuxedo@mailinator.com> writes:
> Ben Morrow wrote:
>
> [...]
>
>> I disagree. If you were to start by picking one small part--even a
>> single line--and working out what it does, you would find you got
>> further than you think before you got stuck. It *will* be hard work, and
>> it *will* take time, but that's not something I can help with.
>
> Sure, I completely agree! However complicated or simple is a relative term
> however.
No, not really. To a beginner, everything *seems* complicated, but
that's simply the result of his current skill level. He's not in a
position to make an informed and objective assessment of any task's
true complexity.
sherm--
--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
------------------------------
Date: Tue, 7 Sep 2010 23:56:17 +0200
From: Tuxedo <tuxedo@mailinator.com>
Subject: Re: Ideal data structure for nested list format?
Message-Id: <i66ce1$tid$02$1@news.t-online.com>
Sherm Pendley wrote:
> Tuxedo <tuxedo@mailinator.com> writes:
[..]
> That's a *very* poor occasion on which to attempt a learning exercise.
> When deadlines are tight and looming, stick with the tools you know.
True enough! I found a simple way to produce what is needed by importing an
html list from a text file and replacing the relevant parts by regex based
on the current URL (filename) in a series of if-blocks and returning the
modified output, which is nearly like typing each html page out separately:
--------- menu.pl -------
#!/usr/bin/perl -w
use warnings;
use strict;
# used for CGI
$this::page = $ENV{DOCUMENT_NAME} || 'undefined';
# test on command line, eg. 'menu.pl page_2.2.html'
if ($this::page eq 'undefined'){
$this::page = "@ARGV";
}
print "Content-Type: text/html\n\n";
my $filename = "menu.txt" ;
my $filedata ;
open my $fh, '<', $filename
or die "open $filename: $!" ;
{
local $/ ;
$filedata = <$fh> ;
}
close $fh
or die "close $filename: $!" ;
$_ = $filedata; # assign filedata to $_
my $complete_string = $filedata;
if ($this::page eq "page_1.1.html"){
$complete_string =~ s/<a
href="page_1.1.html">page_1.1.html<\/a>/page_1.1.html/;
}
if ($this::page eq "page_2.1.html"){
$complete_string =~ s/<a
href="page_2.1.html">page_2.1.html<\/a>/page_2.1.html/;
$complete_string =~ s/page_1.1.html"/page_1.1.html" class="node"/;
}
if ($this::page eq "page_2.2.html"){
$complete_string =~ s/<a
href="page_2.2.html">page_2.2.html<\/a>/page_2.2.html/;
$complete_string =~ s/page_1.1.html"/page_1.1.html" class="node"/;
}
if ($this::page eq "page_3.1.html"){
$complete_string =~ s/<a
href="page_3.1.html">page_3.1.html<\/a>/page_3.1.html/;
$complete_string =~ s/page_1.1.html"/page_1.1.html" class="node"/;
$complete_string =~ s/page_2.2.html"/page_2.2.html" class="node"/;
}
if ($this::page eq "page_3.2.html"){
$complete_string =~ s/<a
href="page_3.2.html">page_3.2.html<\/a>/page_3.2.html/;
$complete_string =~ s/page_2.2.html"/page_2.2.html" class="node"/;
$complete_string =~ s/page_1.1.html"/page_1.1.html" class="node"/;
}
if ($this::page eq "page_2.3.html"){
$complete_string =~ s/<a
href="page_2.3.html">page_2.3.html<\/a>/page_2.3.html/;
$complete_string =~ s/page_1.1.html"/page_1.1.html" class="node"/;
}
print $complete_string;
------
The unmodified list in menu.txt looks as follows:
<style type="text/css">
.node {
font-style: italic;
}
</style>
<ul>
<li><a href="page_1.1.html">page_1.1.html</a>
<ul>
<li><a href="page_2.1.html">page_2.1.html</a></li>
<li><a href="page_2.2.html">page_2.2.html</a>
<ul>
<li><a href="page_3.1.html">page_3.1.html</a></li>
<li><a href="page_3.2.html">page_3.2.html</a></li>
</ul>
</li>
<li><a href="page_2.3.html">page_2.3.html</a></li>
</ul>
</li>
</ul>
So the example perl code is for only six pages, just imagine what it will
look like with 50 or more pages and what kind of hassle that can be to
maintain. In other words, the code could surely win the ugliest perl script
posted here contest. That said, it actually does what is needed in a
roundabout way and given the facts that changes won't be very frequent and
that it's only an html-preprocessing procedure, since static versions will
be served online, it doesn't need to be easy to maintain or even system
resource friendly. In other words, that the code is bloated and a bit hard
to manage won't affect the end result. Nevertheless, this is my primitive
solution by the tools I happen to know, which all they do is to produce
some modified output based on the current URL (if one is matching) and
adding the css html class to some nodes at the right levels for each link.
Any ideas how to improve the code are of course more than welcome, although
I guess the only *real* improvement would mean a nested data structure,
recursion and complex references etc., although that may be easy to most of
you here, I must avoid that for now due to my inability to bugfix such code.
Thanks for any feedback!
Tuxedo
------------------------------
Date: Wed, 8 Sep 2010 00:32:13 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Ideal data structure for nested list format?
Message-Id: <tkuil7-fid2.ln1@osiris.mauzo.dyndns.org>
Quoth Tuxedo <tuxedo@mailinator.com>:
>
> #!/usr/bin/perl -w
>
> use warnings;
> use strict;
>
> # used for CGI
> $this::page = $ENV{DOCUMENT_NAME} || 'undefined';
Don't do that. This is the '$page' variable in the 'this' package; you
should not be randomly stomping on it without good reason. You should
not, in fact, be using global (package) variables at all without good
reason.
my $this_page = $ENV{DOCUMENT_NAME} || 'undefined';
Also, Perl already has a special 'undefined' value for situations like
this, and conveniently enough that is what $ENV{DOCUMENT_NAME} will be
set to if that variable doesn't exist in the environment. So skip the
'|| 'undefined'' part altogether.
> # test on command line, eg. 'menu.pl page_2.2.html'
> if ($this::page eq 'undefined'){
unless (defined $this_page) {
You may prefer to write this as one of
if (not defined $this_page) {
if (!defined $this_page) {
if you aren't familiar with 'unless' yet.
> $this::page = "@ARGV";
This will join the command-line arguments with the current value of $"
(" " by default). Since you're passing and expecting a single argument,
just use that:
$this_page = $ARGV[0];
> }
>
> print "Content-Type: text/html\n\n";
>
> my $filename = "menu.txt" ;
> my $filedata ;
>
> open my $fh, '<', $filename
> or die "open $filename: $!" ;
>
> {
> local $/ ;
> $filedata = <$fh> ;
> }
> close $fh
> or die "close $filename: $!" ;
That's a reasonable way to read the contents of a file, and it's what I
tend to use for quick-and-dirty scripts (well, I usually write it
my $filedata = do {
open my $FH, "<", "...";
local $/;
<$FH>;
};
but thats just compression for compression's sake...). For something
you're going to keep around a while, though, it's considerably clearer
(as well as a smidge faster) to use the File::Slurp module.
> $_ = $filedata; # assign filedata to $_
> my $complete_string = $filedata;
Why do you do either of these? You never use $_ below, and you never
need $filedata again so there's no need to copy it.
> if ($this::page eq "page_1.1.html"){
> $complete_string =~ s/<a
> href="page_1.1.html">page_1.1.html<\/a>/page_1.1.html/;
If you use different delimiters you won't need the backwhack; if you use
the paired-bracket delimiters you can separate the two parts of the s///
and avoid the long lines:
$complete_string =~ s[<a href="page_1.1.html">page_1.1.html</a>]
[page_1.1.html];
> }
>
> if ($this::page eq "page_2.1.html"){
> $complete_string =~ s/<a
> href="page_2.1.html">page_2.1.html<\/a>/page_2.1.html/;
> $complete_string =~ s/page_1.1.html"/page_1.1.html" class="node"/;
> }
This actually makes me want to scream, the amount of code you're writing
out again for every entry, but I expect you could've predicted that :).
At the very least you can observe that the
$complete_string =~ s/<a href="page_1.1.html">page_1.1.html<\/a>/
page_1.1.html/;
bit is the same every time, and write it first (outside the 'if's) as
$complete_string =~ s[<a href="$this_page">$this_page</a>]
[$this_page];
If this isn't your actual code (you *have* read the Posting Guidelines,
right?) and the title is not necessarily the name of the page, you just
need a regex capture:
$complete_string =~ s[<a href="$this_page">(.*?)</a>][$1]s;
The '?' there is important: it stops the pattern matching everything up
to the final '</a>' in the file.
> So the example perl code is for only six pages, just imagine what it will
> look like with 50 or more pages and what kind of hassle that can be to
> maintain. In other words, the code could surely win the ugliest perl script
> posted here contest.
Oh, no, I've seen *much* worse. This is just awkwardly redundant, it's
not actively unreadable :).
> Any ideas how to improve the code are of course more than welcome, although
> I guess the only *real* improvement would mean a nested data structure,
> recursion and complex references etc., although that may be easy to most of
> you here, I must avoid that for now due to my inability to bugfix such code.
One step at a time. Next time you get a chance, look at this again and
see if you can cut down the number of times you write the same thing (or
nearly the same thing) twice. Don't worry that you can't yet see how to
make it 'perfect': if you put it away better than when you got it out,
that's progress.
Ben
------------------------------
Date: Tue, 07 Sep 2010 08:28:33 -0700
From: "John W. Krahn" <jwkrahn@example.com>
Subject: Re: slices
Message-Id: <CSsho.16922$u16.13315@newsfe17.iad>
okey wrote:
> How do I pass just a "slice to mysubsub()? I have an array reference
> to three hashes
>
> $p = [ {a => "1"}, {b => "2"}, {c => "4} ];
>
> mysub($p);
>
>
> sub mysub {
> my ($pF) = @_;
> #every thing ok so far
>
> mysubsub($pF); #passes all three
>
> # want something like this, but can't seem to make it work.
>
> mysubsub(@{$pF->[1..2]})
mysubsub( @{ $pF }[ 1 .. 2 ] )
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
------------------------------
Date: Tue, 07 Sep 2010 18:47:35 +0200
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: slices
Message-Id: <86r5h5sdp4.fsf@gareth.avalon.lan>
okey <oldyork90@yahoo.com> writes:
> How do I pass just a "slice to mysubsub()? I have an array reference
> to three hashes
>
> $p = [ {a => "1"}, {b => "2"}, {c => "4} ];
>
> mysub($p);
>
>
> sub mysub {
> my ($pF) = @_;
> #every thing ok so far
>
> mysubsub($pF); #passes all three
>
> # want something like this, but can't seem to make it work.
>
> mysubsub(@{$pF->[1..2]})
>
That should be
mysubsub( @{$pF}[1..2] }
You first deref the arrayref, then you can slice the resulting
arrray. Of course, you're now passing an array, not a ref, but that if
you need a ref, you can easily fix that.
Mart
--
"We will need a longer wall when the revolution comes."
--- AJS, quoting an uncertain source.
------------------------------
Date: Tue, 07 Sep 2010 11:48:26 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: slices
Message-Id: <slrni8cqnj.ihd.tadmc@tadbox.sbcglobal.net>
John W. Krahn <jwkrahn@example.com> wrote:
> okey wrote:
>> How do I pass just a "slice to mysubsub()? I have an array reference
>> to three hashes
>>
>> $p = [ {a => "1"}, {b => "2"}, {c => "4} ];
>>
>> mysub($p);
>>
>>
>> sub mysub {
>> my ($pF) = @_;
>> #every thing ok so far
>>
>> mysubsub($pF); #passes all three
>>
>> # want something like this, but can't seem to make it work.
>>
>> mysubsub(@{$pF->[1..2]})
>
> mysubsub( @{ $pF }[ 1 .. 2 ] )
I like to apply "Use Rule 1" from perlreftut in 3 steps:
mysubsub( @array[ 1 .. 2 ] ) # pretend it is a plain array (slice)
mysubsub( @{ }[ 1 .. 2 ] ) # replace array name with a block
mysubsub( @{ $pF }[ 1 .. 2 ] ) # fillin block with the right kind of ref
--
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: Tue, 7 Sep 2010 11:28:38 -0700 (PDT)
From: Larry Sulky <larrysulky@gmail.com>
Subject: XML Xpath interrogation
Message-Id: <4ced9350-3166-4036-8509-e4e6f40806be@u6g2000yqh.googlegroups.com>
I have this XML data:
<doc>
<title>Aaa</title>
<para>Ppp</para>
<section type="baz">
<title>Xxx</title>
<para>Qqq</para>
<section>
<title>Mmm</title>
</section>
<title>Yyy</title>
<para>Rrr</para>
</section>
</doc>
Notice that 'doc/section' has two 'title' children. I need to split
'doc/section' in two:
<doc>
<title>Aaa</title>
<para>Ppp</para>
<section type="baz">
<title>Xxx</title>
<para>Qqq</para>
<section>
<title>Mmm</title>
</section>
</section><!-- Insert this -->
<section type="baz"><!-- And this -->
<title>Yyy</title>
<para>Rrr</para>
</section>
</doc>
I need to retain any attributes on the parent of 'title' ('section' in
this example), and I need to handle the occurrence of multiple 'title'
elements within a single parent no matter where they occur. The parent
is not necessarily 'section' and the issue can occur at any hierarchic
level. Extra credit: do NOT split if the 'title' elements are
adjacent; just join them into one element.
I would like a way to interrogate the Xpath of each 'title' and if I
see an identical path except for the final index -- for example, 'doc/
section[1]/title[1]' and 'doc/section[1]/title[2]', be able to throw
the 'section[1]' node into a variable and process it there. What's the
simplest XML package for Perl to do this? Is there another approach
(other than 'title' interrogation) someone can recommend?
Thanks!
------------------------------
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 3124
***************************************