[26549] in Perl-Users-Digest
Perl-Users Digest, Issue: 8691 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 20 21:05:27 2005
Date: Sun, 20 Nov 2005 18:05:04 -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 Sun, 20 Nov 2005 Volume: 10 Number: 8691
Today's topics:
debug stmts; cmd line define <dont_w@nt_spam.org>
Re: debug stmts; cmd line define (Anno Siegel)
Re: debug stmts; cmd line define <dont_w@nt_spam.org>
Re: LWP::Useragent and Javascript function <no@email.com>
Re: LWP::Useragent and Javascript function <tadmc@augustmail.com>
Re: sprintf formating <_nospam_stigerikson@yahoo.se>
Re: sprintf formating <rvtol+news@isolution.nl>
Re: strange problem with system() and backtick operator <news@chaos-net.de>
Re: strange problem with system() and backtick operator <rvtol+news@isolution.nl>
Re: XML Parsing too slow with XML::Simple <bart.lateur@pandora.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 20 Nov 2005 22:38:20 GMT
From: Mike Ballard <dont_w@nt_spam.org>
Subject: debug stmts; cmd line define
Message-Id: <m2wtj3x7t8.fsf@west_f1.net>
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.
Mike
--
------------------------------
Date: 20 Nov 2005 22:51:55 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: debug stmts; cmd line define
Message-Id: <dlqumb$897$1@mamenchi.zrz.TU-Berlin.DE>
Mike Ballard <dont_w@nt_spam.org> wrote in comp.lang.perl.misc:
>
> 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.
Here is one way. In file "program", write
print "debugging\n" if defined &DEBUG and DEBUG();
Run with "perl program", this prints nothing.
Run with "perl -Mconstant=DEBUG,1" program", it prints "debugging".
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Sun, 20 Nov 2005 23:38:46 GMT
From: Mike Ballard <dont_w@nt_spam.org>
Subject: Re: debug stmts; cmd line define
Message-Id: <m2sltqyjky.fsf@west_f1.net>
On Sun Nov 20, I was peacefully napping until Anno Siegel said:
> Mike Ballard <dont_w@nt_spam.org> wrote in comp.lang.perl.misc:
> >
> > 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.
>
> Here is one way. In file "program", write
>
> print "debugging\n" if defined &DEBUG and DEBUG();
>
> Run with "perl program", this prints nothing.
> Run with "perl -Mconstant=DEBUG,1" program", it prints "debugging".
>
Thank you very much; just what I was looking for...
Mike
--
------------------------------
Date: Sun, 20 Nov 2005 19:16:23 +0000
From: Brian Wakem <no@email.com>
Subject: Re: LWP::Useragent and Javascript function
Message-Id: <3uc0c7F1054lnU1@individual.net>
Francis Sylvester wrote:
> Dear all,
>
> I'm trying to scrape a site with LWP::Useragent which contains a
> javascript function (__doPostBack) within the links. From investigation -
> this appears to be an ASP.NET function to validate the client. Does
> anybody know if a Javascript module exists for perl? ...or if anybody is
> familiar with scraping this function or could point me to a site with more
> info I'd really appreciate it. The function appears to post an
> __EVENTTARGET and an __EVENTARGUMENT to the server. I've tried setting
> these in the LWP header but no joy.
Automating stuff on ASP.NET sites is a nightmare.
I think last time I did it I captured the __VIEWSATE and __EVENT... stuff
with regexs and then POSTed the data to the appropriate URL, which worked.
MS are changing the way this works in newer versions of .NET, as they
realised it's bloody stupid to post a 6KB VIEWSTATE to a page which does
very little.
The whole idea is ridiculous anyhow as ~10% of people wont have JS and
therefore can't use any of these sites.
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: Sun, 20 Nov 2005 14:53:04 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: LWP::Useragent and Javascript function
Message-Id: <slrndo1ohf.2lt.tadmc@magna.augustmail.com>
Francis Sylvester <francis@nospam.com> wrote:
> I'm trying to scrape a site with LWP::Useragent which contains a javascript
> function (__doPostBack) within the links. From investigation - this appears
> to be an ASP.NET function to validate the client.
> Does anybody know if a
> Javascript module exists for perl?
You don't need one if you can do in Perl what the Javascript does.
> ...or if anybody is familiar with
> scraping this function or could point me to a site with more info I'd really
> appreciate it.
You first do a GET, and then do a POSTback to the same URL with...
> The function appears to post an __EVENTTARGET and an
> __EVENTARGUMENT to the server.
...some values that were added in the GET's response.
> I've tried setting these in the LWP header
> but no joy.
Show code if you want help fixing the code.
Or, just have this write the Perl code for you:
Web Scraping Proxy
http://www.research.att.com/~hpk/wsp/
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 20 Nov 2005 21:38:51 +0100
From: stig <_nospam_stigerikson@yahoo.se>
Subject: Re: sprintf formating
Message-Id: <dlqn2n$88l$1@oden.abc.se>
Thanks to all and everyone that answered!
------------------------------
Date: Mon, 21 Nov 2005 00:24:19 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: sprintf formating
Message-Id: <dlr4in.1co.1@news.isolution.nl>
stig:
> change the dot to a comma
printf is locale-dependent.
use POSIX qw(strtod);
use locale;
perldoc perllocale
perldoc -f sprintf
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sun, 20 Nov 2005 22:23:06 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: strange problem with system() and backtick operator
Message-Id: <slrndo1q9q.gp.news@maki.homeunix.net>
Dr.Ruud wrote :
> Martin Kissner:
>> but I need a number represented in octal with
>> identical digits (0644).
>
> $val = oct('644'); # $val is now the numeric value 420 (decimal)
>
> printf "%#o\n", $val; # should print 0644
This is what I did first, but I think it's more elegant to calculate the
number which is needed to chmod to the desired permissions than to
calculate a number, convert ist to a string and then convert it to the
number which is needed.
Nevertheless, thank's for your feedback.
Best regards
Martin
--
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'
------------------------------
Date: Mon, 21 Nov 2005 00:28:53 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: strange problem with system() and backtick operator
Message-Id: <dlr4io.1co.1@news.isolution.nl>
Martin Kissner:
> Dr.Ruud:
>> Martin Kissner:
>>> but I need a number represented in octal with
>>> identical digits (0644).
>>
>> $val = oct('644'); # $val is now the numeric value 420 (decimal)
>>
>> printf "%#o\n", $val; # should print 0644
>
> This is what I did first, but I think it's more elegant to calculate
> the number which is needed to chmod to the desired permissions than to
> calculate a number, convert ist to a string and then convert it to the
> number which is needed.
It was not meant as code to use, I just tried to explain to you some of
the differences between value and representation.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sun, 20 Nov 2005 21:30:25 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: XML Parsing too slow with XML::Simple
Message-Id: <8lq1o15b1qrr1fg0lthp3fn3aoicq9hqm3@4ax.com>
jabby wrote:
>I have some files ranging from 6 meg to 15 meg that I need to process
>to input into a database. I'm inheriting some old code using
>XML::Simple and this process is taking forever (an hour or more). I
>have eliminated the database as the time hog in this equation.
I think your problem is the DOM action: loading everything into memory.
Instead, think of parsing in event mode, reading only parts at a time,
like SAX, or XML::Twig.
--
Bart.
------------------------------
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 8691
***************************************