[30367] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1610 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 4 14:09:49 2008

Date: Wed, 4 Jun 2008 11:09:11 -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           Wed, 4 Jun 2008     Volume: 11 Number: 1610

Today's topics:
        ANNOUNCE: Text::CSV_XS <h.m.brand@xs4all.nl>
    Re: Automatically extracting MS Outlook  2007 calendar  <benkasminbullock@gmail.com>
    Re: building goocanvas <benkasminbullock@gmail.com>
    Re: Counting lines in big number of files - in parallel <dalessio@motorola.NOSPAM.com>
    Re: Counting lines in big number of files - in parallel <benkasminbullock@gmail.com>
        How to get the output from an ICQ clent <tvachkov@googlemail.com>
    Re: How to get the output from an ICQ clent <tzz@lifelogs.com>
    Re: MD5 and SHA1 fingerprint from SSL certificates <toralf.foerster@gmx.de>
    Re: OT: SI units <tzz@lifelogs.com>
    Re: OT: SI units <1usa@llenroc.ude.invalid>
    Re: OT: SI units <jurgenex@hotmail.com>
    Re: Perl grep and Perl 4 (Randal L. Schwartz)
    Re: Perl grep and Perl 4 <cwilbur@chromatico.net>
    Re: Receiving snmp traps in perl on Win platform? <dirkvandemoortel@ThankS-NO-SperM.hotmail.com>
    Re: XML::Parser Tree Style <rvtol+news@isolution.nl>
    Re: XML::Parser Tree Style <NiallBCarter@googlemail.com>
    Re: XML::Parser Tree Style <tadmc@seesig.invalid>
    Re: XML::Parser Tree Style <benkasminbullock@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 4 Jun 2008 15:20:08 GMT
From: "H.Merijn Brand" <h.m.brand@xs4all.nl>
Subject: ANNOUNCE: Text::CSV_XS
Message-Id: <K1y3Ay.29A@zorch.sf-bay.org>

The following report has been written by the PAUSE namespace indexer.
Please contact modules@perl.org if there are any open questions.
  Id: mldistwatch.pm 1019 2008-06-01 12:34:41Z k

               User: HMBRAND (H.Merijn Brand)
  Distribution file: Text-CSV_XS-0.46.tgz
    Number of files: 34
         *.pm files: 1
             README: Text-CSV_XS-0.46/README
           META.yml: Text-CSV_XS-0.46/META.yml
  Timestamp of file: Wed Jun  4 15:05:06 2008 UTC
   Time of this run: Wed Jun  4 15:06:35 2008 UTC

2008-06-04  0.46 - H.Merijn Brand   <h.m.brand@xs4all.nl>

        * In examples add die on failed close calls
        * Use Test::MinimumVersion (not distributed)
        * Added option -F to examples/csv2xls
        * More source code cleanup
        * Nailed the UTF-8 issues for parsing
        * Nailed the UTF-8 issues for combining

2008-04-23  0.45 - H.Merijn Brand   <h.m.brand@xs4all.nl>

        * Forgot to pack examples/parser-xs.pl

2008-04-23  0.44 - H.Merijn Brand   <h.m.brand@xs4all.nl>

        * Fixed the error position returned as third arg in error_diag ()
        * Made examples/csv-check use this even more vebose
        * Removed double-double quote from TODO
        * Added examples/parse-xs.pl (attempt to fix bad CSV)




------------------------------

Date: Wed, 4 Jun 2008 12:18:41 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: Automatically extracting MS Outlook  2007 calendar entries with perl (on WIndows)
Message-Id: <g26171$pts$1@ml.accsnet.ne.jp>

On Tue, 03 Jun 2008 22:43:36 +0200, nntpman68 wrote:

> I would like to extract outlook calendar (only local calendar datam no
> server being used) data without having to have outlook running
> permanently or without having to 'crawl' through the menu for exporting
> the calendar data to a format, that I can easily use in my own perl
> scripts (csv / xml / . . .)

Have you tried looking at the Export options of Outlook?

> So I thought about running a cygwon cronjob, checks for updated outlook
> files on the host and exports the data whenever the files are newer than
> the exported data.

You can run jobs like cron on Windows using the "Task Scheduler", which lives 
somewhere down in the Start menu under "System" I think.
  
> I have cygwin and its perl installed, but could also install another
> perl if needed.

You don't need another Perl, the Cygwin one is good enough, but having 
ActiveState Perl is handy if you want to, for example, run scripts from 
Outlook, so your Outlook starts a Perl script.
 
> The ideas I had:
> 
> Parsing the file containg the information:
> ---------------------------------------------
> 
> The options would be to extract the calendar information directly out of
> the file where the information is stored in. Outlook is running only
> locally and not connecting to a server.
> 
> I don't even know which file contains the calendar data: 

I don't know either.

> So at least data is not stored in a
> simple format within these three files.

It's not a simple format in those files, but Outlook can import and export 
calendar data in various formats without using Perl, and that might be the 
right way to go. I used to export my Outlook calendar data into my mobile 
phone, until the mobile phone threw a fit and deleted almost all the calendar 
entries. (wasn't such a big problem since the items just went into the 
"deleted items" folder in Outlook, but still - don't trust Vodafone's calendar 
software.)

> Is there any perl module, which can extract calendar data out of the
> local files of a windows host?

If there is, it's not on CPAN.

> Using a perl script that starts outlook and exports the calendar entry:
> -------------------------------------------------------------------------
> 
> The idea is to let perl  start outlook and do whatever is needed to
> export the calendar data.
> However I have zero experience with any MS specific perl modules and any
> other MS specifics.

It's pretty easy, since all you are doing is basically calling the Outlook 
objects as if writing a VBA (Visual Basic for Applications, the language used 
for macros in Word, Excel, Outlook etc.) script, so you can use the VBA 
documentation and stuff - Microsoft Office is a whole lot more "open" than 
most "open source" things and a lot better documented too.

> Does anyone have a good starting point (tutorials / example scripts /
> urls ) for such a task.

I have quite a lot of stuff about automating Outlook via Perl on a blog:

http://linuxtnt.wordpress.com/?s=outlook

(scroll down a bit for the useful parts). One of these is the fourth hit on 
Google for a search for "outlook perl". By coincidence I have another script I 
made today which I'm planning to put there soon.

There's nothing about calendar entries there, but the format for automation is 
similar for calendar entries - the basic thing is the Items collection and 
then you get members of it and do things etc.



------------------------------

Date: Wed, 4 Jun 2008 13:50:16 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: building goocanvas
Message-Id: <g266io$qvo$1@ml.accsnet.ne.jp>

On Tue, 03 Jun 2008 16:20:45 -0700, deadpickle wrote:

> I want to build goocanvas 0.10 on my windows system. how do I run ./
> configure in windows?

I really don't know. Goocanvas seems to be written in C, not Perl, and 
it's something to do with gtk, so I wonder why you asked here.


------------------------------

Date: Tue, 3 Jun 2008 09:42:16 -0500
From: "Mario D'Alessio" <dalessio@motorola.NOSPAM.com>
Subject: Re: Counting lines in big number of files - in parallel.
Message-Id: <g23lp1$s1i$1@newshost.mot.com>


<hadzio@gmail.com> wrote in message 
news:c4857a09-1348-4b5c-8b42-affc273f949d@k37g2000hsf.googlegroups.com...
> Hi,
>
> I have the following issue. I have a directory with 25000 text files
> in it (about 1-10000 lines in each file). I have a perl script that
> generates some reports for me and this script needs to count the
> number of lines in each of these 25000 files (for each file I need a
> number of lines in it). And it is not so difficult, I iterate over the
> directory and count the number of lines using "wc -l" as follows:
>
> open (WCCOUNT, "cat $file_to_read | wc -l |");
> $file_number_of_lines = <WCCOUNT>;
> chomp($file_number_of_lines);
> close(WCCOUNT);
>
> But the above sequencial counting is very slow (2-3 hours). My server
> is quite powerfull (72 CPU and fast filesystems) so I would like to
> run the counting in parallel (eg. counting in 72 files at the same
> time). So the questions are:
> 1) Is it possible to run the above command (cat ... | wc -l) in
> background & (the same way as in shell) and receive the returned
> results when it is finished.
> 2) Is it possible to implement 1) without threads?
> 3) The above code I may write using system() instead of open(), but
> the same issue is: how to do it in parallel.
>
> Or maybe someone has any other better idea how to count number of
> lines in each of 25000 files? Maye someone may recommend me some other
> solution. Thank you in advance.
>
> Regards
> Pawel

You're using Perl like a batch script. Don't. The first
thing I tell newbies is to let Perl do the work, not external
tools. Your first line above needs to start a shell, run the
"cat" command, and run the "wc" command *for each file*, in
addition to having Perl run. All of this starting and stopping
processes is a waste. Do everything with Perl.

See:
http://www.unix.com.ua/orelly/perl/cookbook/ch08_03.htm


Mario





------------------------------

Date: Wed, 4 Jun 2008 13:56:39 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: Counting lines in big number of files - in parallel.
Message-Id: <g266un$qvo$2@ml.accsnet.ne.jp>

On Tue, 03 Jun 2008 02:14:26 -0700, hadzio wrote:

> Or maybe someone has any other better idea how to count number of
> lines in each of 25000 files?

I wonder why you need to keep counting these files again and again. Do 
all the files change each time you need to look at them? If not, you 
could store the results of counting in a file, and then only recount the 
ones which have been modified since the results file was last updated.




------------------------------

Date: Wed, 4 Jun 2008 06:35:07 -0700 (PDT)
From: potrebitel <tvachkov@googlemail.com>
Subject: How to get the output from an ICQ clent
Message-Id: <9cc6ae46-200b-4839-82be-1af18eb0b71f@34g2000hsh.googlegroups.com>

Hello everybody,

In my script I want to execute and print out the output from the ysm
ICQ clent after logging in.
I tried this

my $pid = open my $readme, "-|", "ysm" or die "Can't fork: $!\n";
while (<$readme>) {
print "$_\n";
}
# at this point is ysm still active and expecting user interaction
kill 9 => $pid;
close $readme;

but executing the script invokes a blank screen whitout any output.
The $pid is still alive, because the loop doesn't terminate.

Could you help me please, many thanks in advance!

KR,
potrebitel


------------------------------

Date: Wed, 04 Jun 2008 09:48:55 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to get the output from an ICQ clent
Message-Id: <861w3d6yso.fsf@lifelogs.com>

On Wed, 4 Jun 2008 06:35:07 -0700 (PDT) potrebitel <tvachkov@googlemail.com> wrote: 

p> In my script I want to execute and print out the output from the ysm
p> ICQ clent after logging in.
p> I tried this

p> my $pid = open my $readme, "-|", "ysm" or die "Can't fork: $!\n";
p> while (<$readme>) {
p> print "$_\n";
p> }
p> # at this point is ysm still active and expecting user interaction
p> kill 9 => $pid;
p> close $readme;

p> but executing the script invokes a blank screen whitout any output.
p> The $pid is still alive, because the loop doesn't terminate.

You can use Expect.pm to pretend a terminal is connected to the
program, if that's the problem.

There's a few ICQ modules on CPAN (e.g. Net::ICQ) that may work better
for you than interacting with `ysm'.

Ted


------------------------------

Date: Wed, 4 Jun 2008 16:21:10 +0000 (UTC)
From: toralf <toralf.foerster@gmx.de>
Subject: Re: MD5 and SHA1 fingerprint from SSL certificates
Message-Id: <g26fdm$6gt$1@registered.motzarella.org>

Martijn Lievaart wrote:

> Seems IO::Socket::SSL cannot do this, at least I could not find it in the 
> documentation. Nothing for it, but use Net::SSLeay directly and hope it's 
> dump_peer_certificate is better, otherwise get dirty with Net::SSLeay and 
> it's SSLeay low level bindings.
>
> M4

Yep, it seems that I've to go into Net::SSLeay  but it's a hard way.
Probably I'll have try to search in other groups too...
-- 
MfG/Sincerely

Toralf Förster
pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6 9DA3




------------------------------

Date: Wed, 04 Jun 2008 10:39:07 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: OT: SI units
Message-Id: <86skvt5hwk.fsf@lifelogs.com>

On Tue, 3 Jun 2008 14:21:22 -0700 (PDT) sheinrich@my-deja.com wrote: 

s> But if a nation, claiming involvement in world leadership, is even
s> after decades not even starting to adopt the actual world wide
s> accepted standards it deservedly gives place to ridicule.

The US is certainly starting to adopt the SI measurements.

9mm weapons, for instance, are quite popular.  We also have "meter
maids/Nazis" (http://en.wikipedia.org/wiki/Parking_attendant).

Ted "there goes Godwin" Zlatanov


------------------------------

Date: Wed, 04 Jun 2008 15:51:34 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: OT: SI units
Message-Id: <Xns9AB378A44BD7Dasu1cornelledu@127.0.0.1>

Ted Zlatanov <tzz@lifelogs.com> wrote in 
news:86skvt5hwk.fsf@lifelogs.com:

> On Tue, 3 Jun 2008 14:21:22 -0700 (PDT) sheinrich@my-deja.com wrote: 
> 
> s> But if a nation, claiming involvement in world leadership, is even
> s> after decades not even starting to adopt the actual world wide
> s> accepted standards it deservedly gives place to ridicule.

 ... 

> We also have "meter maids/Nazis"

But the meaning of the word meter in that expression has nothing to do 
with the metric system.

To meter is to measure. I am finding it increasingly obnoxious (as my 
years in the U.S. add up) that the French decided to impose on the rest 
of the world the one true system of measurement and co-op a generic term 
meaning to measure/measurement for that purpose.

That is almost as obnoxious as polluting a simple UseNet discussion with 
a wholesale criticism of a whole bunch of people just because the OP had 
a data set where temperatures were recorded in Fahrenheit. Oh my! The 
audacity!

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


------------------------------

Date: Wed, 04 Jun 2008 16:03:58 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: OT: SI units
Message-Id: <45fd44l8qvmca1febe1lbkovucojf8otei@4ax.com>

Ted Zlatanov <tzz@lifelogs.com> wrote:
>The US is certainly starting to adopt the SI measurements.
>9mm weapons, for instance, are quite popular.  We also have "meter
>maids/Nazis" (http://en.wikipedia.org/wiki/Parking_attendant).

:-)) 
YMMD, but couldn't you have warned me? Now I have to clean the monitor.

jue


------------------------------

Date: Wed, 04 Jun 2008 09:09:55 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl grep and Perl 4
Message-Id: <86abi1dvvw.fsf@blue.stonehenge.com>

>>>>> "Charlton" == Charlton Wilbur <cwilbur@chromatico.net> writes:

>>>>> "f" == fourfour2  <fourfour2@gmail.com> writes:
f> Yep - this works when using Perl 5.  Unfortunately not in Perl
f> 4.035 though.

Charlton> Why are you using Perl 4?  Why are you using a version of Perl 4 that
Charlton> isn't the latest version?

The difference between 4.035 and 4.036 was a very trivial patch, although
I think it was a security patch.  I'm not good at recalling things
from a decade ago, though. :)

print "Just another Perl hacker,"; # the original

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


------------------------------

Date: Wed, 04 Jun 2008 13:00:07 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Perl grep and Perl 4
Message-Id: <86y75ldtk8.fsf@mithril.chromatico.net>

>>>>> "RLS" == Randal L Schwartz <merlyn@stonehenge.com> writes:

>>>>> "Charlton" == Charlton Wilbur <cwilbur@chromatico.net> writes:
>>>>> "f" == fourfour2  <fourfour2@gmail.com> writes:

    f> Yep - this works when using Perl 5.  Unfortunately not in Perl
    f> 4.035 though.

    Charlton> Why are you using Perl 4?  Why are you using a version of
    Charlton> Perl 4 that isn't the latest version?

    RLS> The difference between 4.035 and 4.036 was a very trivial
    RLS> patch, although I think it was a security patch.  I'm not good
    RLS> at recalling things from a decade ago, though. :)

Oh, right, but there's something pathological here - using Perl 4
instead of Perl 5, and then, in this day and age, where you have to go
through extra effort to get Perl 4 in the first place, not using the
latest version, trivial patch or no.

Charlton



-- 
Charlton Wilbur
cwilbur@chromatico.net


------------------------------

Date: Wed, 4 Jun 2008 18:34:49 +0200
From: "Dirk Van de moortel" <dirkvandemoortel@ThankS-NO-SperM.hotmail.com>
Subject: Re: Receiving snmp traps in perl on Win platform?
Message-Id: <Wuz1k.117511$zc6.40990@newsfe29.ams2>

Dirk Van de moortel <dirkvandemoortel@ThankS-NO-SperM.hotmail.com> wrote in message
  xuV0k.74432$x55.46478@newsfe17.ams2
> {
>   OOPS, posted this to moderated group perl.cpan.discuss as
>   well, so it can take a while to get through, if it gets through at all
>   Otherwise sorry for duplicate posting
> }
> 
> We need to set up a server 2003 (or a win XP system) to accept
> and act upon traps sent out from a storage system. Responding
> to various error conditions, this system can be fully configured to
> send traps.
> 
> I am wondering what must be done on the trap-accepting side.
> 

Got it.

Dirk Vdm


------------------------------

Date: Wed, 4 Jun 2008 10:14:38 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: XML::Parser Tree Style
Message-Id: <g25q5s.1f0.1@news.isolution.nl>

szr schreef:
> Dr.Ruud:
>> NiallBCarter:

>>> $parser = new XML::Parser( Style => 'Tree' );
>>
>> Better written as
>>
>>  $parser = XML::Parser->new( Style => 'Tree' );
>
> I think better is really in the eye of the beholder. True, there may
> be certain reasons to use the direct  CLASS->new  style over the
> indirect new CLASS  style, but the indirect could be used just as
> well when done correctly. After all, in Perl, TMTOWTDI :-)

Of course you can look at this in that way, but then you would only be
fooling yourself.

Discouraging indirect syntax is a good standard here. Just like
mentioning lexical file handles and three argument opens and the evil of
string eval, over and over again. I wouldn't mind seeing an article with
those points flying by here every week.


Now first check out the "Indirect Object Syntax" section in perlobj.

Further:
http://use.perl.org/~chromatic/journal/33317

"indirect object syntax Just Doesn't Work according to a complex series
of rules that almost no one can explain properly"

"The indirect object syntax can break depending on which methods someone
has declared in other namespaces. It's hardly "pathological" to use
namespaces. In my mind, it's silly to hope that those collisions never
occur. They're not easy to debug."

"I see the indirect object syntax as susceptible to breaking due to
action at a distance. When you load a module that otherwise behaves as a
properly-encapsulated black box, it may do things that cause the
indirect object constructor calls to fail."

See also http://markmail.org/message/3g7ujgdkrg7t2sqq
Etc.

-- 
Affijn, Ruud

"Gewoon is een tijger."



------------------------------

Date: Wed, 4 Jun 2008 02:19:17 -0700 (PDT)
From: NiallBCarter <NiallBCarter@googlemail.com>
Subject: Re: XML::Parser Tree Style
Message-Id: <cf5431bf-7459-416d-9285-2646362f4990@m45g2000hsb.googlegroups.com>

Right, notes taken.

I will go away and go through the perlreftutu, perlref and web
examples to figure out refs.
Thanks for all explaining some of the commands.

On Tue, 03 Jun 2008 14:59, Ben Bullock wrote:
> my $stuff = Dumper( $tree );
>$stuff =~ s/\s//g;
>while ($stuff =~/firstname.*?(\w+)'\]/g) {
>    print "$1\n";

Thanks Ben but when I run this code I get the following:
Attempt to bless into a reference at /usr/lib64/perl5/vendor_perl/
5.8.8/x86_64-linux-thread-multi/XML/Parser.pm line 107.
???????

SO now I need to go and think about array refs.
Just to throw a spanner in the works, I have also been fooling around
with LibXML which was recommended by a perlmonk and it seems very
simple - the immediate advantage is that it allows XPATH style access
and also allows me to write out XML a little more simply.
My question is this:
Ultimatly I wish to parse through my XML document, remove firstname
and lastname, place them in an array (done, we have been through this)
and then remove them out of array, place them into variables which can
be used to construct another document; does LibXML provide perhaps a
simpler mechanism for doing so?

Thanks kindly for all your help, this has proven to be the far most
helpful and warmest help[ group I have found.

N

 Tad McClellan wrote:
>   print "FOUND\n\n", XML::XPath::XMLParser::as_string($node), "\n\n";

All well and good Tad but XML::Path is not installed and I have been
told that it will not be installed.




------------------------------

Date: Tue, 3 Jun 2008 22:21:00 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: XML::Parser Tree Style
Message-Id: <slrng4c2gs.64g.tadmc@tadmc30.sbcglobal.net>

szr <szrRE@szromanMO.comVE> wrote:
> Dr.Ruud wrote:
>> NiallBCarter schreef:
>>
>>> $parser = new XML::Parser( Style => 'Tree' );
>>
>> Better written as
>>
>>  $parser = XML::Parser->new( Style => 'Tree' );
>
> I think better is really in the eye of the beholder. 


It is an effective way to insert subtle bugs into your code.

   perldoc -q method

      Why can't a method included in this same file be found?
      ...
      Make sure to read about creating modules in L<perlmod> and
      the perils of indirect objects in L<perlobj/"Method Invocation">.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Wed, 4 Jun 2008 12:40:50 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: XML::Parser Tree Style
Message-Id: <g262gi$qik$1@ml.accsnet.ne.jp>

On Wed, 04 Jun 2008 02:19:17 -0700, NiallBCarter wrote:

> On Tue, 03 Jun 2008 14:59, Ben Bullock wrote:

You've posted a reply to my message but according to the message it's
a followup to "Dr. Ruud". That might have prevented me from even
seeing your message at all, so I wouldn't have even known about your reply.

>> my $stuff = Dumper( $tree );
>>$stuff =~ s/\s//g;
>>while ($stuff =~/firstname.*?(\w+)'\]/g) {
>>    print "$1\n";
> 
> Thanks Ben but when I run this code I get the following: Attempt to
> bless into a reference at /usr/lib64/perl5/vendor_perl/
> 5.8.8/x86_64-linux-thread-multi/XML/Parser.pm line 107. ???????

Dunno, sorry. Are you sure you didn't alter anything in the file? Try
copying it out again.

> SO now I need to go and think about array refs. 

Here is a thing which unwraps the references from your program (this
runs on my computer)

#!/usr/bin/perl

use strict;
use warnings;

use XML::Parser;
use Data::Dumper;

my $xml=<<EOF;
<?xml version='1.0' encoding='UTF-8'?>
<list name="Nialls list">
	<person>
		<firstname>Niall</firstname>
		<lastname>Carter</lastname>
		<age>24</age>
	</person>
	<person>
			<firstname>Ruth</firstname>
			<lastname>Brewster</lastname>
			<age>22</age>
	</person>
	<person>
			<firstname>Cas</firstname>
			<lastname>Creer</lastname>
			<age>23</age>
	</person>
</list>
EOF
my $p = new XML::Parser( Style => 'Tree' );
my $tree = $p->parse($xml);
my $dog = 1;
print ref $dog,"\n";
#exit;

my $depth = 0;

sub recursively_descend
{
    $depth++;
    my $indent = '   'x$depth;
    my ($thing) = @_;
    if (!ref($thing)) {
	if ($thing =~ /^\s+$/) {
	    print "whitespace\n";
	} else {
	    print "'$thing'\n";
	}
    } elsif (ref($thing) eq 'ARRAY') {
	print "ARRAY\n";
	my $count = 0;
	for my $k (@{$thing}) {
	    print $indent,"$count:";
	    recursively_descend ($k);
	    $count++;
	}
    } elsif (ref($thing) eq 'HASH') {
	my @k = keys %{$thing};
	if (@k) {
	    print "HASH: keys @k\n";
	} else {
	    print "HASH: empty\n";
	}
	for my $b (@k) {
	    print $indent,"$b:"; 
	    recursively_descend ($$thing{$b});
	}
    } elsif (ref($thing) eq 'SCALAR') {
	print "SCALAR '$$thing'\n";
    }
    $depth--;
}
recursively_descend ($tree);

>  Tad McClellan wrote:
>>   print "FOUND\n\n", XML::XPath::XMLParser::as_string($node), "\n\n";
> 
> All well and good Tad but XML::Path is not installed and I have been
> told that it will not be installed.

You can install it locally in your own account.

Note that since Tad McClellan may not even have seen this, to get a better
response I recommend that you reply to Tad McClellan in a separate
message as a direct followup to him. The Usenet reading software that
most people use is set up so that the threads of conversation are
visible.


------------------------------

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 V11 Issue 1610
***************************************


home help back first fref pref prev next nref lref last post