Guest_imported
New member
- Jan 1, 1970
- 0
I am doing a search through text.
The search goes in the format of:
$text =~ /$pattern/i
to make it case insensitive.
What i really want is to make it case insensitive depending on a variable.
Now I know that I COULD do it by having if clauses at every search...
but there are a LOT of searches and that would make the script inefficient.
Therefore i have the line at the top saying:
$case = "i" if ($sensitive eq "no"
;
$case = "" if ($sensitive eq "yes"
;
And i want all of my search lines (and there are a LOT) to say:
$text =~ /$pattern/$case
however it interprets it as a non scalar and falls over.
In what format, if any, an i put the $case in order to make it search with
or without
i dependent on $case without having two lines of if... else at each search.
Thanks a lot guys
Gareth
Thermeon Europe Ltd
Gbjk@carsplus.co.uk
The search goes in the format of:
$text =~ /$pattern/i
to make it case insensitive.
What i really want is to make it case insensitive depending on a variable.
Now I know that I COULD do it by having if clauses at every search...
but there are a LOT of searches and that would make the script inefficient.
Therefore i have the line at the top saying:
$case = "i" if ($sensitive eq "no"
$case = "" if ($sensitive eq "yes"
And i want all of my search lines (and there are a LOT) to say:
$text =~ /$pattern/$case
however it interprets it as a non scalar and falls over.
In what format, if any, an i put the $case in order to make it search with
or without
i dependent on $case without having two lines of if... else at each search.
Thanks a lot guys
Gareth
Thermeon Europe Ltd
Gbjk@carsplus.co.uk