M
Martin Daser
Hello *,
I am currently writing a small script to search various patterns within
files.
Therefore I am looping over a bunch of strings and try to find the
pattern. Optionally I want to set a variable to certain flags, which can
be appended to the matching operator. The variable is either empty or
contains some switches/characters.
Adding the variable which holds the switches results in a syntax error:
Scalar found where operator expected at /...../rgrep line 88, near
"m/($word)/$matchopts"
syntax error at /...../rgrep line 88, near "m/($word)/$matchopts"
syntax error at /...../rgrep line 96, near "}"
Execution of /...../rgrep aborted due to compilation errors.
Here is the excerpt to give you an idea:
# set option for ignore case matching; others possible
$matchopts = "i";
.....
# the next line would be line 88
if ($_ =~ m/($word)/$matchopts)
{
.....
}
Is there a way to avoid this error? How can I get around it?
Any help is appreciated! Thanks in advance!
-- Martin
I am currently writing a small script to search various patterns within
files.
Therefore I am looping over a bunch of strings and try to find the
pattern. Optionally I want to set a variable to certain flags, which can
be appended to the matching operator. The variable is either empty or
contains some switches/characters.
Adding the variable which holds the switches results in a syntax error:
Scalar found where operator expected at /...../rgrep line 88, near
"m/($word)/$matchopts"
syntax error at /...../rgrep line 88, near "m/($word)/$matchopts"
syntax error at /...../rgrep line 96, near "}"
Execution of /...../rgrep aborted due to compilation errors.
Here is the excerpt to give you an idea:
# set option for ignore case matching; others possible
$matchopts = "i";
.....
# the next line would be line 88
if ($_ =~ m/($word)/$matchopts)
{
.....
}
Is there a way to avoid this error? How can I get around it?
Any help is appreciated! Thanks in advance!
-- Martin