[26551] in Perl-Users-Digest
Perl-Users Digest, Issue: 8693 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 21 14:05:45 2005
Date: Mon, 21 Nov 2005 11:05:05 -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 Mon, 21 Nov 2005 Volume: 10 Number: 8693
Today's topics:
Re: debug stmts; cmd line define <bugbear@trim_papermule.co.uk_trim>
Re: debug stmts; cmd line define <bugbear@trim_papermule.co.uk_trim>
Extrating String using Split <Ashwin@DoNot@Email.com>
Re: Extrating String using Split xhoster@gmail.com
Trouble in wantarray context (Ronald Fischer)
Re: Trouble in wantarray context xhoster@gmail.com
Re: XML Parsing too slow with XML::Simple <mirod@mirod.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 21 Nov 2005 14:51:13 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: debug stmts; cmd line define
Message-Id: <4381dee1$0$9505$ed2619ec@ptn-nntp-reader02.plus.net>
Mike Ballard wrote:
> Been looking around usenet and am not finding what I'm looking for; how do
> I put statements in perl code for debug only (like printfs or whatever)
> and then actvate/define them from the command line? I know using cpp I
> can "-D<>" for ifdef statements and am looking for the same kind of thing
> for perl.
If you're doing anything of "significant" you might try:
http://log4perl.sourceforge.net/
BugBear
------------------------------
Date: Mon, 21 Nov 2005 14:52:47 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: debug stmts; cmd line define
Message-Id: <4381df3f$0$9505$ed2619ec@ptn-nntp-reader02.plus.net>
Mike Ballard wrote:
> Been looking around usenet and am not finding what I'm looking for; how do
> I put statements in perl code for debug only (like printfs or whatever)
> and then actvate/define them from the command line? I know using cpp I
> can "-D<>" for ifdef statements and am looking for the same kind of thing
> for perl.
Addendum:
http://www.perl.com/pub/a/2002/09/11/log4perl.html
BugBear
------------------------------
Date: Mon, 21 Nov 2005 14:29:40 GMT
From: "Ashwin" <Ashwin@DoNot@Email.com>
Subject: Extrating String using Split
Message-Id: <xn0ea0cuu8kb7lx000@news.europe.nokia.com>
Hi All
I have following code,
my $Loc="C:\\Temp\\testing_disp\\Internal";
my
@alldir=("C:\\Temp\\testing_disp\\Internal\\A","C:\\Temp\\testing_disp\\
Internal\\B","C:\\Temp\\testing_disp\\Internal\\C");
where A,B,C are deeper directory tree what I need, is to split so that
I get directory tree A,
The problem if I use below code it complains
my @finaldir=map((split(/$Loc/))[1],@alldir);
Unrecognized escape \T passed through before HERE mark in regex m/C:\T
<< HERE emp\testing_disp\Internal/
even
@finaldir=map(/$Loc(.*)/,@alldir);
fails with the same error
even if I remove reference to "c:" I still cannot split
Question is how to extract rest of tree;
--
------------------------------
Date: 21 Nov 2005 18:25:52 GMT
From: xhoster@gmail.com
Subject: Re: Extrating String using Split
Message-Id: <20051121132552.981$Hc@newsreader.com>
"Ashwin" <Ashwin@DoNot@Email.com> wrote:
> Hi All
> I have following code,
>
> my $Loc="C:\\Temp\\testing_disp\\Internal";
> my
> @alldir=("C:\\Temp\\testing_disp\\Internal\\A","C:\\Temp\\testing_disp\\
> Internal\\B","C:\\Temp\\testing_disp\\Internal\\C");
>
> where A,B,C are deeper directory tree what I need, is to split so that
> I get directory tree A,
>
> The problem if I use below code it complains
> my @finaldir=map((split(/$Loc/))[1],@alldir);
> Unrecognized escape \T passed through before HERE mark in regex m/C:\T
> << HERE emp\testing_disp\Internal/
>
> even
> @finaldir=map(/$Loc(.*)/,@alldir);
> fails with the same error
> even if I remove reference to "c:" I still cannot split
Read about \Q in perldoc perlretut.
>
> Question is how to extract rest of tree;
something like: /\Q$Loc\E(.*)/
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 21 Nov 2005 15:10:36 GMT
From: u235321044@spawnkill.ip-mobilphone.net (Ronald Fischer)
Subject: Trouble in wantarray context
Message-Id: <l.1132585836.1503906250@proxy22-ic-ext.fth.sbs.de>
Does someone have an elegant solution to the following problem?
Consider a function F which is supposed to do the following:
(1) Perform X()
(2) Perform Y(); Y returns a different result in array- or
scalar context. The result of Y should be returned as the
result of F (which hence is also sensitive to array- vs.
scalar context)
(3) Perform Z() (which may do some cleanup-work, which can be
done only after Y has been executed).
Under these premises, what is an elegant way to code F? Here is
one straightforward, but not-so-elegant solution:
sub F()
{
X();
if(wantarray)
{ my @result=Y(); Z(); @result }
else
{ my $result=Y(); Z(); $result }
}
This works, and might be acceptable in this simple case, but
it is a bit awkward, because Z() has be repeated in both
branches, and there are two exit points instead of one.
Maybe someone can improve on this?
Ronald
--
Sent by mn-pg-p-e-b-consultant-3.com from siemens piece from com
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-replayer.com
------------------------------
Date: 21 Nov 2005 18:42:53 GMT
From: xhoster@gmail.com
Subject: Re: Trouble in wantarray context
Message-Id: <20051121134253.758$Sr@newsreader.com>
u235321044@spawnkill.ip-mobilphone.net (Ronald Fischer) wrote:
> Does someone have an elegant solution to the following problem?
>
> Consider a function F which is supposed to do the following:
>
> (1) Perform X()
>
> (2) Perform Y(); Y returns a different result in array- or
> scalar context. The result of Y should be returned as the
> result of F (which hence is also sensitive to array- vs.
> scalar context)
>
> (3) Perform Z() (which may do some cleanup-work, which can be
> done only after Y has been executed).
>
> Under these premises, what is an elegant way to code F? Here is
> one straightforward, but not-so-elegant solution:
>
> sub F()
> {
> X();
> if(wantarray)
> { my @result=Y(); Z(); @result }
> else
> { my $result=Y(); Z(); $result }
> }
>
> This works, and might be acceptable in this simple case, but
> it is a bit awkward, because Z() has be repeated in both
> branches, and there are two exit points instead of one.
>
> Maybe someone can improve on this?
warn "untested";
use AtExit;
sub F()
{
my $scope1 = AtExit->new(\&Z);
X();
return Y();
}
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 21 Nov 2005 16:46:26 +0100
From: Michel Rodriguez <mirod@mirod.org>
Subject: Re: XML Parsing too slow with XML::Simple
Message-Id: <4381ebd3$0$8495$5fc30a8@news.tiscali.it>
A. Sinan Unur wrote:
> Well, after seeing this, I became curious, and downloaded
> your benchmark code at
>
> <URL:http://www.xmltwig.com/article/simple_benchmark/simple_benchmark.tar.gz>
>
> Tried to run the script run_all, but:
>
> D:\Dload\simple_benchmark> perl run_all
> Can't find string terminator "'" anywhere before EOF at -e line 1.
> -uThe system cannot find the file specified.
> Module versions:
> Can't find string terminator "'" anywhere before EOF at -e line 1.
> -uThe system cannot find the file specified.
> Can't call method "size" on an undefined value at run_all line 41.
>
> is all I get.
>
> I am on Windows XP SP2 with Perl 5.8.7
Oops!
Sorry for the screw-up, a combination of not testing the tar file in a
separate directory (it missed a library) and code rot. I fixed it,
hopefully, at the same address. Under Windows you won't get the memory
used (it's Linux-dependant). You need xmllint in the path too.
--
mirod
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8693
***************************************