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

Discussion in 'Perl Misc' started by laredotornado, Nov 12, 2010.

  1. 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
     
    laredotornado, Nov 12, 2010
    #1
    1. Advertisements

  2. laredotornado

    Willem Guest

    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
     
    Willem, Nov 12, 2010
    #2
    1. Advertisements

  3. Re: Can't figure out why I'm getting "Bareword found where operator expected ..."

    laredotornado <> writes:

    > 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
     
    Peter Makholm, Nov 12, 2010
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rinus Luijmes
    Replies:
    1
    Views:
    1,247
    TopoGrafix
    Aug 3, 2005
  2. Replies:
    2
    Views:
    971
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,797
    Smokey Grindel
    Dec 2, 2006
  4. Tom Mountney
    Replies:
    6
    Views:
    1,591
    Mathias Panzenboeck
    Nov 21, 2006
  5. Neil

    Can't figure out why scanf does this

    Neil, Nov 18, 2006, in forum: C Programming
    Replies:
    8
    Views:
    434
    CBFalconer
    Nov 19, 2006
  6. Frankie Montenegro

    Compiler returns error, can't figure out why

    Frankie Montenegro, Oct 16, 2005, in forum: C++
    Replies:
    6
    Views:
    414
    Jim Langston
    Oct 19, 2005
  7. Doug  Wright

    Code is leaking and I can't figure out why

    Doug Wright, Mar 11, 2006, in forum: Javascript
    Replies:
    5
    Views:
    202
    Thomas 'PointedEars' Lahn
    Mar 17, 2006
  8. Replies:
    3
    Views:
    158
Loading...