Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: bareword error

by johngg (Canon)
on Mar 13, 2008 at 23:42 UTC ( [id://674110]=note: print w/replies, xml ) Need Help??


in reply to bareword error

A couple of points:

  • You are doing a match, not an assignment so use =~ rather than =.

  • Is the second slash in your m//http|html|HTML|A HREF|a href/i intended or a typo? It is why you are getting a bareword error because you are matching against an empty pattern (m// which actually means last successful match, thanks hipowls for pointing that out) and the 'http' that follows is the bareword. If intended, either escape it with a backslash (m/\/http..../) or change the delimiter used to something other than a forward slash (m{/http....}).

I hope this is helpful.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: bareword error
by hipowls (Curate) on Mar 14, 2008 at 10:49 UTC

    Good answer, one error though, m// is not an empty pattern, it is the last pattern to successfully match, split gets special dispensation so that split m//, $stuff does split on an empty pattern.

    From the split reference:

    As a special case for split, using the empty pattern // specifically matches only the null string, and is not be confused with the regular use of // to mean "the last successful pattern match". So, for split, the following:
    print join(':', split(//, 'hi there'));
    produces the output 'h:i: :t:h:e:r:e'.

      Cripes, I'd never realised that, thanks for pointing it out. I had to write a little piece of code to prove it to myself.

      $ perl -le ' > $s1 = q{catDOGfish}; > $s2 = q{xxYYYzz}; > print $1 if $s1 =~ m{([A-Z]+)}; > print $1 if $s1 =~ m{([0-9]+)}; > print $1 if $s2 =~ m{};' DOG YYY $

      Fancy not knowing that after all this time!

      Thanks again,

      JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://674110]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-19 18:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found