Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: string matching

by hippo (Bishop)
on Jan 26, 2017 at 23:31 UTC ( [id://1180409]=note: print w/replies, xml ) Need Help??


in reply to string matching

The short answer is that you have an asterisk where you should have a space. So your if test might become:

if ($desc =~ /;FTP : /)

The longer answer is that if you are searching for a fixed string like this it is usually both more efficient and less error prone to use index instead of a regex match in the first place. eg:

if (index ($desc, ';FTP : ') > -1)

If you only want to trigger when $desc starts with that string (rather than containing it anywhere) then look for the index value being precisely zero.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-13 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found