Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Can't figure out why I'm getting "Bareword found where operatorexpected ..." (http://www.velocityreviews.com/forums/t914159-cant-figure-out-why-im-getting-bareword-found-where-operatorexpected.html)

laredotornado 11-12-2010 05:21 PM

Can't figure out why I'm getting "Bareword found where operatorexpected ..."
 
Hi,

I'm using Perl 5.8.9 for Mac 10.6.3. I'm found an expression to match
URLs in text (http://www.truerwords.net/articles/ut/
urlactivation.html), but I'm getting a syntax error for my line ...

if ($error_text =~ m/(^|[ \t\r\n])
((ftp|http|https|gopher|mailto|news|nntp|telnet|wa is|file|prospero|aim|
webcal):(([A-Za-z0-9$_.+!*(),;/?:@&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-
Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&~=%-]*))?([A-Za-z0-9$_+!*();/?:~-]))/) {


Specifically, the errors are

Bareword found where operator expected at log_analyzer.pl line 92,
near "%[A"
(Missing operator before A?)
syntax error at log_analyzer.pl line 92, near "?:"
syntax error at log_analyzer.pl line 93, near ""found url: $error_text
\n";"
Unmatched right curly bracket at log_analyzer.pl line 108, at end of
line
syntax error at log_analyzer.pl line 108, near "}"

Can anyone provide guidance as to how I can cure these syntax errors?
Thanks, - Dave

Willem 11-12-2010 05:35 PM

Re: Can't figure out why I'm getting "Bareword found where operatorexpected ..."
 
laredotornado wrote:
) Hi,
)
) I'm using Perl 5.8.9 for Mac 10.6.3. I'm found an expression to match
) URLs in text (http://www.truerwords.net/articles/ut/
) urlactivation.html), but I'm getting a syntax error for my line ...
)
) if ($error_text =~ m/(^|[ \t\r\n])
) ((ftp|http|https|gopher|mailto|news|nntp|telnet|wa is|file|prospero|aim|
) webcal):(([A-Za-z0-9$_.+!*(),;/?:@&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-
) Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&~=%-]*))?([A-Za-z0-9$_+!*();/?:~-]))/) {

You need to escape the slashes.
Or use a different delimiter for the m// operator.


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

Peter Makholm 11-12-2010 05:36 PM

Re: Can't figure out why I'm getting "Bareword found where operator expected ..."
 
laredotornado <laredotornado@zipmail.com> writes:

> if ($error_text =~ m/(^|[ \t\r\n])
> ((ftp|http|https|gopher|mailto|news|nntp|telnet|wa is|file|prospero|aim|
> webcal):(([A-Za-z0-9$_.+!*(),;/?:@&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-
> Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&~=%-]*))?([A-Za-z0-9$_+!*();/?:~-]))/) {


You got five '/' in that line and the match operator is terminated by
the second. So the rest of the line is actually junk code which
confuses perl in different ways. You should either use another
seperartor or escape the slashes in you regexp.

//Makholm


All times are GMT. The time now is 02:05 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.