Hello,
I would like to write a regexp that can be either case sensitive or that can
ignore the case based on a variable (value would be either 'i' or '').
For instance in the below code the variable is $case.
I can't make that piece of code working fine. Anyone can help please ?
my $str = "Hello World!";
my $pattern "hello";
my $case = "i";
if ($str =~ s/${pattern}/${case}) {
print "match!\n";
}
Thank you,
Pierre.
I would like to write a regexp that can be either case sensitive or that can
ignore the case based on a variable (value would be either 'i' or '').
For instance in the below code the variable is $case.
I can't make that piece of code working fine. Anyone can help please ?
my $str = "Hello World!";
my $pattern "hello";
my $case = "i";
if ($str =~ s/${pattern}/${case}) {
print "match!\n";
}
Thank you,
Pierre.
Comment