Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Problem with input strings that have "[]" brackets

by golux (Chaplain)
on May 09, 2015 at 01:36 UTC ( #1126161=note: print w/replies, xml ) Need Help??


in reply to Problem with input strings that have "[]" brackets

Please also note that when looking for a pattern contained as a substring of a line, it can be much simpler and clearer to use the index function:
my $line = ' [Category("notestrecord")]'; my $pattern = 'Category("notestrecord")'; if (index($line, $pattern) >= 0) { print "We have a match!\n"; } else { print "No match!\n"; }
The index function gives a negative one if the match wasn't found, and the position of the match if it was (which can be a zero if the match was at the beginning), hence the comparison of zero or greater:
if (index($line, $pattern) >= 0) { ... }
say  substr+lc crypt(qw $i3 SI$),4,5

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2020-12-06 01:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (65 votes). Check out past polls.

    Notices?