[23532] in Perl-Users-Digest
Perl-Users Digest, Issue: 5741 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 2 09:05:56 2003
Date: Sun, 2 Nov 2003 06:05:08 -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, 2 Nov 2003 Volume: 10 Number: 5741
Today's topics:
Re: extracting properties of companies with a tag for c (Vumani Dlamini)
Re: extracting properties of companies with a tag for c <noreply@gunnar.cc>
how to automate webpage interaction? <mizhael@yahoo.com>
Re: how to automate webpage interaction? (John J. Lee)
Stupid regex problem... <eurleif@ecritters.biz>
Re: Stupid regex problem... <tassilo.parseval@rwth-aachen.de>
Re: Stupid regex problem... <ak+usenet@freeshell.org>
Re: Stupid regex problem... <kaspREMOVE_CAPS@epatra.com>
Re: Stupid regex problem... <eurleif@ecritters.biz>
Re: Stupid regex problem... <abigail@abigail.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Nov 2003 23:44:16 -0800
From: dvumani@hotmail.com (Vumani Dlamini)
Subject: Re: extracting properties of companies with a tag for company number
Message-Id: <4b35f3c9.0311012344.53b8956@posting.google.com>
> You may not start a conditional construct with 'elsif'.
> No parentheses surrounding the $i variable, or else you capture the
> value of $i at the next line, which is not what you want.
This did the trick. Just changed the first 'elsif' to 'if' and
everything worked. Also had to change the captured variable to $2.
> Your code includes a couple of other bugs, but this should be enough
> to help you fix them by yourself.
Maybe, I don't seem to know exactly how to ask the questions, but I
felt this time I had a lot of detail???
Thanks a lot.
Vumani
------------------------------
Date: Sun, 02 Nov 2003 10:03:44 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: extracting properties of companies with a tag for company number
Message-Id: <bo2hi9$16geh8$1@ID-184292.news.uni-berlin.de>
Vumani Dlamini wrote:
>> You may not start a conditional construct with 'elsif'. No
>> parentheses surrounding the $i variable, or else you capture the
>> value of $i at the next line, which is not what you want.
>
> This did the trick. Just changed the first 'elsif' to 'if' and
> everything worked. Also had to change the captured variable to $2.
I doubt that the last elsif statement matched:
> elsif (/PROPemp(\d+)c=(\d+)/) {
-----------------------------^
>> Your code includes a couple of other bugs, but this should be
>> enough to help you fix them by yourself.
>
> Maybe, I don't seem to know exactly how to ask the questions, but I
> felt this time I had a lot of detail???
Personally I think that the level of detail is fine. Bob gave you some
good advice, even if I think he missed that the fact that the code
didn't compile was the reason why you asked for help.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 2 Nov 2003 00:39:07 -0500
From: "walala" <mizhael@yahoo.com>
Subject: how to automate webpage interaction?
Message-Id: <bo259a$71f$1@mozo.cc.purdue.edu>
Dear all,
I try to use Perl to automating the log-on process to 'mail.yahoo.com'
webpage. Here is my program:
---------------------------------------------------
use Clone;
use WWW::Automate;
my $agent = WWW::Automate->new();
$url='mail.yahoo.com';
$agent->get($url);
#$agent->follow($link);
$agent->form(2);
$agent->field($name, $value);
$agent->click($button);
$agent->back();
$agent->add_header($name => $value);
print "OK" if $agent->{content} =~ /$expected/;
-----------------------------------------------------------
However, it gives error message that "there is no form number 2"...
Can anybody tell me what is the form number of that "login" and "passwd"
field in "mail.yahoo.com"?
And how to find it out?
Thanks a lot,
-Walala
------------------------------
Date: 02 Nov 2003 13:36:05 +0000
From: jjl@pobox.com (John J. Lee)
Subject: Re: how to automate webpage interaction?
Message-Id: <87y8uyj3ju.fsf@pobox.com>
"walala" <mizhael@yahoo.com> writes:
> I try to use Perl to automating the log-on process to 'mail.yahoo.com'
> webpage. Here is my program:
[...]
> However, it gives error message that "there is no form number 2"...
>
> Can anybody tell me what is the form number of that "login" and "passwd"
> field in "mail.yahoo.com"?
Everybody and their dog has written a script to fetch mail from
mail.yahoo.com. If this isn't just a little problem you've set
yourself, use one of those instead.
> And how to find it out?
I guess form(2) is the second form on the page (assuming this module
uses HTML::Form, it'll count from 1, not 0). So look in the HTML for
your <FORM>...</FORM>, and count how many forms there are in the page
before that. Add one. That's your form number.
John
------------------------------
Date: Sun, 02 Nov 2003 13:01:49 GMT
From: Leif K-Brooks <eurleif@ecritters.biz>
Subject: Stupid regex problem...
Message-Id: <1f7pb.203$au6.138256@monger.newsread.com>
I have the following Perl code. When I run it, Perl complains that $1 is
undefined. If I change (foo)|(bar) to (bar)|(foo), it works fine. I know
I could just use /(foo|bar)/, but this is just a simplified example.
use strict;
use warnings;
my $text = 'bar';
if ($text =~ /(?:(foo)|(bar))/) {
print $1;
}
------------------------------
Date: 2 Nov 2003 13:09:38 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Stupid regex problem...
Message-Id: <bo2vmi$srl$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Leif K-Brooks:
> I have the following Perl code. When I run it, Perl complains that $1 is
> undefined. If I change (foo)|(bar) to (bar)|(foo), it works fine. I know
> I could just use /(foo|bar)/, but this is just a simplified example.
>
> use strict;
> use warnings;
>
> my $text = 'bar';
> if ($text =~ /(?:(foo)|(bar))/) {
> print $1;
> }
You have two capturing pairs of parens of which only one will (or none
actually) can match. There is the special variable $+ (see perlvar.pod)
which holds the actual match:
my $text = 'bar';
if ($text =~ /(?:(foo)|(bar))/) {
print $+;
}
__END__
bar
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sun, 2 Nov 2003 13:10:13 +0000 (UTC)
From: Andreas Kahari <ak+usenet@freeshell.org>
Subject: Re: Stupid regex problem...
Message-Id: <slrnbqa0hg.1a4.ak+usenet@mx.freeshell.org>
In article <1f7pb.203$au6.138256@monger.newsread.com>, Leif K-Brooks wrote:
> I have the following Perl code. When I run it, Perl complains that $1 is
> undefined. If I change (foo)|(bar) to (bar)|(foo), it works fine. I know
> I could just use /(foo|bar)/, but this is just a simplified example.
>
> use strict;
> use warnings;
>
> my $text = 'bar';
> if ($text =~ /(?:(foo)|(bar))/) {
> print $1;
> }
>
You never actually posed a question, so I will assume that you
meant "Why does is $1 undefined?".
Well, the regex as a whole matches, and the part that matched
the first parenthesis is stored in $1 and the part that matches
the second parentesis is stored in $2. Clearly, nothing matches
the first parenthesis, so $1 will be undefined.
--
Andreas Kähäri
------------------------------
Date: Sun, 2 Nov 2003 18:45:21 +0530
From: "Kasp" <kaspREMOVE_CAPS@epatra.com>
Subject: Re: Stupid regex problem...
Message-Id: <bo301d$uom$1@newsreader.mailgate.org>
> my $text = 'bar';
> if ($text =~ /(?:(foo)|(bar))/) {
> print $1;
> }
$1 stores the (foo) match
$2 stores the (bar) match
As you yourself pointed out, (foo|bar) is better as the result is stored in
$1.
HTH
--
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert.
------------------------------
Date: Sun, 02 Nov 2003 13:13:07 GMT
From: Leif K-Brooks <eurleif@ecritters.biz>
Subject: Re: Stupid regex problem...
Message-Id: <Dp7pb.204$au6.138514@monger.newsread.com>
Tassilo v. Parseval wrote:
> You have two capturing pairs of parens of which only one will (or none
> actually) can match.
Ok, that makes sense. I was assuming the parens would only store if they
were the ones used in the alternation. Is there any way to make that happen?
------------------------------
Date: 02 Nov 2003 13:58:47 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Stupid regex problem...
Message-Id: <slrnbqa3cn.vgs.abigail@alexandra.abigail.nl>
Leif K-Brooks (eurleif@ecritters.biz) wrote on MMMDCCXV September
MCMXCIII in <URL:news:Dp7pb.204$au6.138514@monger.newsread.com>:
## Tassilo v. Parseval wrote:
##
##
## > You have two capturing pairs of parens of which only one will (or none
## > actually) can match.
##
## Ok, that makes sense. I was assuming the parens would only store if they
## were the ones used in the alternation. Is there any way to make that happen?
Sort of.
if ($text =~ /(foo)/ || $text =~ /(bar)/) {
print $1;
}
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
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 5741
***************************************