[32517] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3782 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 24 03:09:21 2012

Date: Mon, 24 Sep 2012 00:09:04 -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           Mon, 24 Sep 2012     Volume: 11 Number: 3782

Today's topics:
        Can't find a syntax error, hoping a second set of eyes  <jwcarlton@gmail.com>
    Re: Can't find a syntax error, hoping a second set of e <ben@morrow.me.uk>
    Re: Can't find a syntax error, hoping a second set of e <uri@stemsystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 23 Sep 2012 21:09:43 -0700 (PDT)
From: Jason C <jwcarlton@gmail.com>
Subject: Can't find a syntax error, hoping a second set of eyes will help
Message-Id: <6f96b5a2-30e7-4980-aedd-af4c6ac72320@googlegroups.com>

Can someone look at this and tell me what I'm messing up? I've been coding all night, and my eyes have gone fuzzy :-)

while ($text =~ #<a[^>]* href=(["'])*[^\1>]*\1[^>]*?>(.*?)</a>#gsi) {
  if ($2 =~ /^http/i) {
    $text =~ s#<a[^>]*? href=(["'])*([^\1>]*)\1[^>]*?>(.*?)</a>#$2#gsi;
  }
}

The error is on the while() line (at least, I remove it and no more error). The error just says:

syntax error at blah.cgi line 239, near "if"
syntax error at blah.cgi line 246, near "}"

The purpose of the function is to remove the <a href=...></a> code in submitted text, but only if the linked text begins with http.

TIA,

Jason


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

Date: Mon, 24 Sep 2012 05:52:55 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Can't find a syntax error, hoping a second set of eyes will help
Message-Id: <7i55j9-5dk.ln1@anubis.morrow.me.uk>


Quoth Jason C <jwcarlton@gmail.com>:
> Can someone look at this and tell me what I'm messing up? I've been
> coding all night, and my eyes have gone fuzzy :-)
> 
> while ($text =~ #<a[^>]* href=(["'])*[^\1>]*\1[^>]*?>(.*?)</a>#gsi) {
                 ^^ m

(I would suggest finding a highlighting editor. It makes this sort of
syntactic mistake much easier to spot.)

Ben



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

Date: Mon, 24 Sep 2012 01:22:39 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Can't find a syntax error, hoping a second set of eyes will help
Message-Id: <87pq5cm1uo.fsf@stemsystems.com>

>>>>> "JC" == Jason C <jwcarlton@gmail.com> writes:

  JC> Can someone look at this and tell me what I'm messing up? I've been coding all night, and my eyes have gone fuzzy :-)
  JC> while ($text =~ #<a[^>]* href=(["'])*[^\1>]*\1[^>]*?>(.*?)</a>#gsi) {

why do you think the # marks the start of a regex? only if you use m//
can you change the regex delim from /.
and ^ will not invert a char class for \1 as \1 isn't a char class
element. so even if you fix the regex delim, that will fail. finally,
why are you parsing out urls with a regex when there are modules that do
it correctly?

uri



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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 3782
***************************************


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