Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by golux (Chaplain)
on May 09, 2015 at 01:36 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1126161]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found