in reply to seek and replace for exceptional characters
As toolic points out, quotemeta will ensure all the rules are followed.
An example using quotemeta to ensure grep works properly:
foreach my $searchString (@requestedSearches) { my $searchRegex = quotemeta $searchString; my @matchesFound = grep /$searchRegex/, @dataStore; ... # Do something with @matchesFound }
And, before you ask, no, there is no inverse function to quotemeta, but a search on PerlMonks will reveal some theoretical almost-reverse techniques that could come in handy some day. :-)
|
|---|