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

L

laredotornado

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|wais|file|prospero|aim|
webcal):(([A-Za-z0-9$_.+!*(),;/?:mad:&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-
Z0-9][a-zA-Z0-9$_.+!*(),;/?:mad:&~=%-]*))?([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
 
W

Willem

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|wais|file|prospero|aim|
) webcal):(([A-Za-z0-9$_.+!*(),;/?:mad:&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-
) Z0-9][a-zA-Z0-9$_.+!*(),;/?:mad:&~=%-]*))?([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
 
P

Peter Makholm

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top