[19845] in Perl-Users-Digest
Perl-Users Digest, Issue: 2040 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 31 06:05:27 2001
Date: Wed, 31 Oct 2001 03:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1004526307-v10-i2040@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 31 Oct 2001 Volume: 10 Number: 2040
Today's topics:
About tailing ... <edgue@web.de>
Re: About tailing ... (Anno Siegel)
Re: CGI param/regex difficulties <simon.oliver@umist.ac.uk>
DB app without MySQL inserted_id <mmanso@yahoo.com>
Re: Design questions about fork(), pipe() and sockets <edgue@web.de>
Re: Help Please <bart.lateur@skynet.be>
Passing variables from Perl script to shell script (Rashyid)
Re: Passing variables from Perl script to shell script (Anno Siegel)
Re: Passing variables from Perl script to shell script <tintin@snowy.calculus>
Perl for Win32 FAQ relocated <bert@scanlaser.nl>
Re: Perl from NT OS to Linux/Unix <bart.lateur@skynet.be>
Re: Private instance variables in Objects ?? <simon.oliver@umist.ac.uk>
Re: Searching - CGI (Tad McClellan)
Re: Security- Upload scripts (Tad McClellan)
Re: Useless use of private hash in void context (Mike Wangu)
when does 0.58 != 0.58? <peb@bms.umist.ac.uk>
Re: when does 0.58 != 0.58? <peb@bms.umist.ac.uk>
Re: when does 0.58 != 0.58? <bart.lateur@skynet.be>
Wrapping long emails - sample code (Philip S Tellis)
Re: Wrapping long emails - sample code <bernard.el-hagin@lido-tech.net>
Re: XML parsing (Spike)
Re: XSL Processor (Matt Sergeant)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 31 Oct 2001 10:39:03 +0100
From: Edwin =?iso-8859-1?Q?G=FCnthner?= <edgue@web.de>
Subject: About tailing ...
Message-Id: <3BDFC6B7.2FA48921@web.de>
Hi,
I was writing some test code to tail log files.
The perlfaq says:
First try
seek(GWFILE, 0, 1);
The statement "seek(GWFILE, 0, 1)" doesn't change the current
position, but it does clear the end-of-file condition on the
handle, so that the next <GWFILE> makes Perl try again to read
something.
Well, so I wrote this program here:
use strict;
my $infile = $ARGV[0];
open (HANDLE, $infile) or die("Couldnt open file: $infile: $!\n");
while (1) {
while (<HANDLE>) {
print "Line number $. is : $_";
}
# seek(HANDLE, 0, 1);
sleep(1);
}
And well - it doesnt matter if the comment is there or not.
In other words: tailing seems to work with and without doing
a seek. I am simply wondering why the FAQ tells me to use seek()
here.
------------------------------
Date: 31 Oct 2001 10:27:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: About tailing ...
Message-Id: <9rojnf$aj6$2@mamenchi.zrz.TU-Berlin.DE>
According to Edwin Günthner <edgue@web.de>:
> Hi,
>
> I was writing some test code to tail log files.
> The perlfaq says:
>
> First try
>
> seek(GWFILE, 0, 1);
>
> The statement "seek(GWFILE, 0, 1)" doesn't change the current
> position, but it does clear the end-of-file condition on the
> handle, so that the next <GWFILE> makes Perl try again to read
> something.
>
> Well, so I wrote this program here:
>
> use strict;
>
> my $infile = $ARGV[0];
>
> open (HANDLE, $infile) or die("Couldnt open file: $infile: $!\n");
>
> while (1) {
> while (<HANDLE>) {
>
> print "Line number $. is : $_";
> }
> # seek(HANDLE, 0, 1);
> sleep(1);
> }
>
> And well - it doesnt matter if the comment is there or not.
> In other words: tailing seems to work with and without doing
> a seek. I am simply wondering why the FAQ tells me to use seek()
> here.
Some file system implementations need the seek(), others don't.
To be portable, leave it in.
Anno
------------------------------
Date: Wed, 31 Oct 2001 10:04:15 +0000
From: Simon Oliver <simon.oliver@umist.ac.uk>
To: Bert IJff <bert@scanlaser.nl>
Subject: Re: CGI param/regex difficulties
Message-Id: <3BDFCC9F.77E8FC5A@umist.ac.uk>
Hence the correction next in thread.
Bert IJff wrote:
>
> Simon Oliver wrote:
>
> > And please correct me if I'm wrong but which OS uses \012\015? As far as
> > I know:
> >
> > Unix = \015
> > Win32 = \015\012
> > Mac = \012
> >
> Wrong ;-)
> Unix = \012
> Win32 = \015\012
> Mac = \015
------------------------------
Date: Wed, 31 Oct 2001 10:22:23 +0000
From: "Miguel Manso" <mmanso@yahoo.com>
Subject: DB app without MySQL inserted_id
Message-Id: <pan.2001.10.31.10.22.23.324.8334@yahoo.com>
Hi there.
I will start developing a project soon that's built on Perl + DBI +
MySQL.
I've been using DBI for some time now and with MySQL I know it gives me
an mysql_insertedid (or something like that) with the ID of the last
record inserted on a table.
This is great when developing MySQL apps but the problem begins when we
want to port the application to another platform (Oracle, for example).
My question is, does anyone has an "elegant" solution for this? I mean,
handle inserted id's, auto_increments, etc on a generic way (or sort of)
so that porting application could be a wonderful thing... ;)
Thanks...
--
Miguel Manso - <mmanso@prodigio.com>
Departamento Técnico
Prodigio - Produções Digitais Online, S.A.
Tel: +351 22 0106000 - Fax: +351 22 0106001
------------------------------
Date: Wed, 31 Oct 2001 09:30:02 +0100
From: Edwin =?iso-8859-1?Q?G=FCnthner?= <edgue@web.de>
Subject: Re: Design questions about fork(), pipe() and sockets
Message-Id: <3BDFB68A.D92E1B2B@web.de>
David Efflandt wrote:
> Wouldn't it be easier to simply have one process write to the log file and
> the other independent processes read and display any changes?
Maybe ...
> There's also a File::Tail module from CPAN.
At least the latest version wont run (it needs Time::HiRes, and
Time::HiRes wont work on OS/2).
I will see if the other alternatives might work.
------------------------------
Date: Wed, 31 Oct 2001 10:29:24 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Help Please
Message-Id: <nhkvttc4nrpuep7ld8ie4klabc10chu6eh@4ax.com>
Scott Blatz wrote:
>[Tue Oct 30 19:48:14 2001] [error] (2)No such file or directory: exec of
>/home/my-site/public_html/cgi-bin/adminpro.cgi failed
>
>I have #! /usr/sbin/perl set correctly, according to my host.
Yet I think it must be the shebang line. It's not unlikely that it's
those pesky CR's, as Louis Erickson wrote.
--
Bart.
------------------------------
Date: 31 Oct 2001 02:03:10 -0800
From: rra@excite.com (Rashyid)
Subject: Passing variables from Perl script to shell script
Message-Id: <79c1319c.0110310203.536bb529@posting.google.com>
Hi there all.. newbie here needs help
ok this is what ive done
#!/usr/perl5/bin/perl
system (/home0/program2 abc);
where program 2 is a unix script that only has the below
print $1
i get an error saying
home0/program2:print:not found
it should just print out abc, right?
What am i doing wrong here?
tried backticks and exec.. get the same thing
Anyone can help me here?
Thanks
Redza
------------------------------
Date: 31 Oct 2001 10:21:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Passing variables from Perl script to shell script
Message-Id: <9rojbq$aj6$1@mamenchi.zrz.TU-Berlin.DE>
According to Rashyid <rra@excite.com>:
> Hi there all.. newbie here needs help
>
> ok this is what ive done
>
> #!/usr/perl5/bin/perl
>
> system (/home0/program2 abc);
>
>
> where program 2 is a unix script that only has the below
>
> print $1
That doesn't look like a unix script. You probably want "echo" instead
of "print". Have you tested the script from the command line?
Anno
------------------------------
Date: Wed, 31 Oct 2001 21:36:39 +1100
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: Passing variables from Perl script to shell script
Message-Id: <otQD7.14$6s7.260195@news.interact.net.au>
"Rashyid" <rra@excite.com> wrote in message
news:79c1319c.0110310203.536bb529@posting.google.com...
> Hi there all.. newbie here needs help
>
> ok this is what ive done
>
> #!/usr/perl5/bin/perl
>
> system (/home0/program2 abc);
Doesn't even compile. Did you cut and paste your code?
>
>
> where program 2 is a unix script that only has the below
>
> print $1
>
> i get an error saying
> home0/program2:print:not found
Again, you should cut and paste the *real* error.
>
> it should just print out abc, right.
Only if you are using a shell that has the 'print' command (eg: ksh).
*hint*, what happens when you run the script from the command line.
>
> What am i doing wrong here?
Apart from your bad cut and paste skills, you need to understand which area
is causing your errors.
------------------------------
Date: Wed, 31 Oct 2001 10:48:59 +0100
From: Bert IJff <bert@scanlaser.nl>
Subject: Perl for Win32 FAQ relocated
Message-Id: <3BDFC90B.5371A045@scanlaser.nl>
Hi all
The Perl for Win32 FAQ link in the idiots guide at
http://www.cpan.org/doc/FAQs/cgi/idiots-guide.html
is broken.
It seems to have moved to
http://www.dnai.com/~evangelo/people/evangelo/Perl_for_Win32_FAQ.html
Regards,
Bert
------------------------------
Date: Wed, 31 Oct 2001 10:32:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl from NT OS to Linux/Unix
Message-Id: <sokvttorkk3abhvbto9l4ju6qvgcdhihdi@4ax.com>
Straatvark wrote:
>"Error Message: Permission denied
Have you properly chmod'ed the file?
--
Bart.
------------------------------
Date: Wed, 31 Oct 2001 10:17:13 +0000
From: Simon Oliver <simon.oliver@umist.ac.uk>
Subject: Re: Private instance variables in Objects ??
Message-Id: <3BDFCFA9.894D493A@umist.ac.uk>
Real Newbie wrote:
>
> Is there a way to create private variables in Perl Objects? If yes,
> can someone give me a brief code example ...
In perl object security is based on trust and as such the user of a
class should only use documented features. As a rule object attributes
should only be accessed via published accessor methods. If the user
decides to look through your code and use your private variables and
then something breaks that's his fault not yours!
Alos, in general, private things in perl start with an underscore as a
warning.
There are methods available for creating private attributes but they are
compicated at not really necessary. See perltooc - "Privacy and
Responsibility" for more information.
--
Simon Oliver
------------------------------
Date: Wed, 31 Oct 2001 05:12:00 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Searching - CGI
Message-Id: <slrn9tuu9n.p5.tadmc@tadmc26.august.net>
Geoff Clark <gclark@wavetel.com> wrote:
>Could someone help me with this search I am trying to do.
I've already tried to do that a few times, but I'm game for
another round.
>The code is as
>follows. The problem I am having it is displaying the file to the screen I
>want to be able to search on the file.
I already showed you how to search the file.
>#!/usr/bin/perl
use warnings;
use strict;
Ask for all the help you can get.
>use CGI qw/:standard/;
>
>print "Content-type:text/html\n\n";
>$dest = param ('mac');
>print <<EndHTML;
[snip a bunch of irrelevant HTML]
>EndHTML
>
>read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
What is that for? You never access $buffer below, and you have
the CGI.pm module for that anyway.
>@lines =`cat 10_1_64_0` ;
>@lines= sort @lines;
my @lines = sort `cat 10_1_64_0` ;
>foreach $lines(@lines){
Oh. You don't need the @lines temporary variable at all:
foreach my $lines (sort `cat 10_1_64_0`) {
> $a=substr($lines,0,2);
> if ($a!="00"){
if ( $lines !~ /^00/ ) { # another temp var eliminated
> $lines =~ /([A-Za-z0-9]*)\s(\w*)\s([\d\d.]*)/;
^^
^^
Useless use of \d. Putting it in the char class once is enough.
I showed you how to do it using split(). It is easier.
Why are you not using split() ?
I expect most or all of those asterisks should be plus signs...
> push (@dhcp,$3." ".$1);
Warning Will Robinson!
Never use the dollar-digit variables unless you have first
tested to ensure that the match succeeded.
If the pattern should ever happen to not match, you will put
values from one of the *previous* iterations of the loop into
@dhcp. Your data will get all mish-mashed.
my @fields = split /\s+/, $lines;
push @dhcp, "$fields[2] $fields[0]"; # 3rd field, then 1st field
>$searchstr = $FORM{'mac'};
>
>@results = grep(/$searchstr/i,@dhcp);
>$found = 0;
>if ($results >= 0) {
^
^
You have a typo there. This is the first mention of $results. Did
you mean @results instead?
If you had "use strict" turned on, it would have found this bug for you.
Enable strict!
And the test is useless anyway. If there are zero elements in
@results then the foreach loop below will execute zero times.
No need for such a test.
> foreach $i (@results) {
> chomp($i);
> ($mac,$ip) = split(/\|/,$i);
^^
^^
Uhh, you put spaces between them, not vertical bars...
> if ($mac =~ $searchstr) {
A pattern match should *look like* a pattern match:
if ($mac =~ /$searchstr/) {
Get your program working from the command line before trying
it as a CGI program.
Don't put "CGI" in your Subject when the problem you are having
has nothing to do with CGI programming.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 31 Oct 2001 05:12:01 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Security- Upload scripts
Message-Id: <slrn9tuug7.p5.tadmc@tadmc26.august.net>
spamfree <spamfree@go-away.net> wrote:
>> > Any recommended resources/tuts on the many security
perldoc perlsec
>> >issues using upload
>> > scripts in perl to Unix?
>>
>> Make sure it starts with:
>>
>> #!/usr/bin/perl -wT
>> use strict;
>>
>>
>Software error:
>Insecure dependency in open while running with -T switch
If you put:
use diagnostics;
near the top of your program and run it again...
>What exactly does this mean and what can I do about it?
... then perl will tell you what it means and what you can
do about it.
Or, you can look up the message yourself:
perldoc perldiag
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 31 Oct 2001 02:02:29 -0800
From: mwangu@yahoo.com (Mike Wangu)
Subject: Re: Useless use of private hash in void context
Message-Id: <ca9aa2d8.0110310202.72461e1d@posting.google.com>
Clinton,
Thank you for your prompt response. Your assessment is right on the
money. This line was a throwback from a previous version of my module,
and was not modified appropriately (at all).
What I was attempting to do in the new version, combine two hashrefs
into one, is better as:
$projtree->{$spdata[0]} = {
%{ $projtree->{$spdata[0]} },
%{ $self->gettree($spdata[3], $recurse) }
};
Thank you, again, for your assistance.
Mike
clintp@geeksalad.org (Clinton A. Pierce) wrote in message news:<PNFD7.212444$K6.104041398@news2>...
> [Posted and mailed]
>
> In article <ca9aa2d8.0110300846.6d58b914@posting.google.com>,
> mwangu@yahoo.com (Mike Wangu) writes:
> > [Lots and lots of stuff deleted]
> > #XX# Problem line below
> > $projtree->{$spdata[0]} = ( %binfo, $self->gettree($spdata[3],
> > $recurse) );
> >
> > This all works fine on the whole. The problem I am having is the error:
> > line 120 (#1)
> >
> > [LINE 120 IS THE LINE AFTER #XX# IN THE SNIPPET ABOVE]
>
> Let's simplify what you've said above:
>
> $p->{foo}=(%h, .....)
>
> What context is %h in? The thing on the left of the assignment is a scalar value.
> The parens on the right therefore are in a scalar context. In a scalar context
>
> (a, b, c)
>
> Evaluates "a", "b" and "c" in void or scalar context and returns c. It does not
> do any kind of amalgamation in scalar context. Your hash there is a useless
> appendage. It's evaluated in a void context, it's value isn't used or needed and
> you're ignoring it.
>
> What I suspect you wanted to say was one of:
>
> $p->{foo}={ %h, $s->g(...) };
>
> or
>
> $p->{foo}=[ %h, $s->g(...) };
>
> Which has scalar things on the right and the left of the assignment.
>
> [And DO NOT fall into the trap of:
>
> $p->{foo}=\(%h, ...);
>
> either. It doesn't do what you want at all.]
------------------------------
Date: Wed, 31 Oct 2001 10:36:08 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: when does 0.58 != 0.58?
Message-Id: <3BDFD418.371FED9F@bms.umist.ac.uk>
Hi all,
I've been having a problem with a script & I've narrowed it down to a
floating point comparison. Basically I want to do something with a load
of data if a variable is equal to 0.58. All sounds easy right? good.
Problem is that a comparison of my variable with 0.58 is false, even
when the variable is 0.58.
Here's a little code to clarify :-
CODE1
perl -MDevel::Peek -le 'for(my $a = 0.56; $a < 0.60; $a += 0.02){print
"\nComparing ";Dump $a;print "with 0.56\n";if($a == 0.56){print "They
are the same!"}else{print "They are different!"}}'
<OUTPUT1>
Comparing
SV = NV(0x8124f30) at 0x80fa2a8
REFCNT = 1
FLAGS = (PADBUSY,PADMY,NOK,pNOK)
NV = 0.56
with 0.56
They are the same!
Comparing
SV = NV(0x8124f30) at 0x80fa2a8
REFCNT = 1
FLAGS = (PADBUSY,PADMY,NOK,pNOK)
NV = 0.58
with 0.56
They are different!
</OUTPUT1>
All is fine here.
CODE2
perl -MDevel::Peek -le 'for(my $a = 0.56; $a < 0.60; $a += 0.02){print
"\nComparing ";Dump $a;print "with 0.58\n";if($a == 0.58){print "They
are the same!"}else{print "They are different!"}}
<OUTPUT2>
Comparing
SV = NV(0x8124f50) at 0x80fa2a8
REFCNT = 1
FLAGS = (PADBUSY,PADMY,NOK,pNOK)
NV = 0.56
with 0.58
They are different!
Comparing
SV = NV(0x8124f50) at 0x80fa2a8
REFCNT = 1
FLAGS = (PADBUSY,PADMY,NOK,pNOK)
NV = 0.58
with 0.58
They are different!
</OUTPUT2>
Er... so what's going on here?
Paul
------------------------------
Date: Wed, 31 Oct 2001 10:44:37 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: when does 0.58 != 0.58?
Message-Id: <3BDFD615.411889AB@bms.umist.ac.uk>
Paul Boardman wrote:
> perl -MDevel::Peek -le 'for(my $a = 0.56; $a < 0.60; $a += 0.02){print
> "\nComparing ";Dump $a;print "with 0.56\n";if($a == 0.56){print "They
> are the same!"}else{print "They are different!"}}'
Let me add a little more information. The reason for the 'for' loop in
the above code is that this is how the variable in the original script
is created. If the comparison is done on a variable not created in a
loop then the comparison returns true.
i.e.
perl -MDevel::Peek -le '$a = 0.58;print "\nComparing ";Dump $a;print
"with 0.58\n";if($a == 0.58){print "They are the same!"}else{print "They
are different!"}'
<OUTPUT>
Comparing
SV = NV(0x8124f20) at 0x8105110
REFCNT = 1
FLAGS = (NOK,pNOK)
NV = 0.58
with 0.58
They are the same!
</OUTPUT>
Is this a bug or am I doing something stupid?
Cheers
Paul
------------------------------
Date: Wed, 31 Oct 2001 10:55:05 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: when does 0.58 != 0.58?
Message-Id: <udlvttoh7k1e77dii212913j1dn3vmvda2@4ax.com>
Paul Boardman wrote:
>Problem is that a comparison of my variable with 0.58 is false, even
>when the variable is 0.58.
>
>Here's a little code to clarify :-
>perl -MDevel::Peek -le 'for(my $a = 0.56; $a < 0.60; $a += 0.02){print
>"\nComparing ";Dump $a;print "with 0.56\n";if($a == 0.56){print "They
>are the same!"}else{print "They are different!"}}'
See the FAQ, perlfaq4 (top of document):
Why am I getting long decimals (eg, 19.9499999999999) instead of the
numbers I should be getting (eg, 19.95)?
The gist of it is that 0.58 and other similar numbers, do not have an
exact internal representation in floating point format. After all, these
floats are based on a binary representation, thus the exponent is base
2. A number like $m/(2**$n), for example 3/8, has an exact
representation, for (sufficiently small) non-negative integer values $n,
and integer $m.
But not 0.56 or 0.58, 100 is not a power of 2.Thus, (approx.) 0.56 plus
(approx.) 0.02 is approx. 0.58, but depending on how you get at that
result, the approximation might be slightly different, in the lowest
bits.
If possible, do your calculations in cents, thus 56 and 2 instead of
0.56 and 0.02. Integers do have an exact internal representation. Or,
using sprintf, round down to 2 decimals. Or, dirty trick: compare as
text.
--
Bart.
------------------------------
Date: 30 Oct 2001 23:36:54 -0800
From: philip@ncst.ernet.in (Philip S Tellis)
Subject: Wrapping long emails - sample code
Message-Id: <d1eff1dd.0110302336.51c41ee4@posting.google.com>
Just thought that some people may be interested in this code. I use
it to wrap long lines in emails that I receive.
#!/usr/bin/perl -pw
use strict;
use Text::Wrap;
BEGIN {
$Text::Wrap::columns=72;
}
s/^((?:[>}|%]\s?)+)(\s*)//o;
my $leadin = $1 || "";
my $leadin_firstline = $leadin . ($2 || "");
$_ = Text::Wrap::wrap($leadin_firstline, $leadin, $_);
__END__
The equivalent command line is (wrapped to fit):
perl -MText::Wrap=wrap,$columns -pe \
'BEGIN {$columns=72}
s/^((?:[>}|%]\s?)*)(\s*)(.+)$/wrap(($1||"").($2||""),$1||"",$3)/goose'
------------------------------
Date: Wed, 31 Oct 2001 08:18:30 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: Wrapping long emails - sample code
Message-Id: <slrn9tvcgm.3nk.bernard.el-hagin@gdndev25.lido-tech>
On 30 Oct 2001 23:36:54 -0800, Philip S Tellis <philip@ncst.ernet.in> wrote:
> Just thought that some people may be interested in this code. I use
> it to wrap long lines in emails that I receive.
>
> #!/usr/bin/perl -pw
>
> use strict;
> use Text::Wrap;
>
> BEGIN {
> $Text::Wrap::columns=72;
> }
>
> s/^((?:[>}|%]\s?)+)(\s*)//o;
^^^
Why the 'o' option?
Cheers,
Bernard
------------------------------
Date: 31 Oct 2001 01:16:55 -0800
From: just.ice@mailcity.com (Spike)
Subject: Re: XML parsing
Message-Id: <25e4dd8c.0110310116.5c9a5ad6@posting.google.com>
Thanks for the advice, people!
I have tried out XML::Twig and it seems to do what I want it to.
I am now able to deal with the records one at a time quite easily.
Works great!
Spike
Bart Lateur <bart.lateur@skynet.be> wrote in message news:<heautt081vefuvamfckhoa0g5d8iifamut@4ax.com>...
> Spike wrote:
>
> >Hi. I am new to XML parsing and have enherited some code which uses
> >XMl::Simple.
> >This reads in the entire XML file and parses it into a data structure.
> >However, when a large file is encountered the machine runs out of
> >memory.
> >
> >Is there some other way to deal with these XML files rather than the
> >way outlined above? Perhaps a module which deals with the file in a
> >step-wise fashion?
>
> I'm currently facing the same problem. I have a database saved as XML in
> the following structure:
>
> <?xml version="1.0"?>
> <database>
> <record id="a123">
> ...
> </record>
> <record id="b456">
> ...
> </record>
> <record id="c789">
> ...
> </record>
> </database>
>
> Since this can contain up to tens of thousands of records, I'd like to
> process them one at a time. I do prefer a tree-like appoach.
>
> Anyway, after some looking around, I found this module which looks
> promising: XML::Twig. It is on CPAN.
>
> XML::Twig - A perl module for processing huge XML documents in
> tree mode.
>
> If your problem is similar to mine, at least check out "ex_fm2" in the
> examples archive that is available through
> <http://standards.ieee.org/resources/spasystem/twig/>. In my case, I'd
> have to set a handler for the "record" element, and this one would be
> called when a whole record has been read. You can access the whole
> subtree under that element in that handler.
------------------------------
Date: 31 Oct 2001 02:31:44 -0800
From: msergeant@star.net.uk (Matt Sergeant)
Subject: Re: XSL Processor
Message-Id: <eb3031b9.0110310231.7e82b44@posting.google.com>
"Zoom Zoom Zoom" <nospam@nospam.com> wrote in message news:<E7BD7.90686$gT6.47754411@news1.rdc1.sfba.home.com>...
> I am using ActiveState Perl on Win2K Server. I can't find this package using
> ppm If I do search xml, it does not show XSL:LibXSLT I did download
> XML::Xalan from cpan.org but looks like even it needs to be "build". I want
> to know if there are just plain binaries available for any of these modules?
C:\> ppm
ppm> set repository RK http://theoryx5.uwinnipeg.ca/ppmpackages/
ppm> set save
ppm> install XML::LibXML
ppm> install XML::LibXSLT
PS: you shouldn't post to c.l.perl - it's supposed to be defunct.
Please use c.l.p.misc instead. I'd set followups, but you can't via
google groups.
------------------------------
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.
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 2040
***************************************