Hi, I'm hoping someone out there can save me the bother of searching through the manuals. Is there any way of telling Perl not to treat reserved characters (+, * etc) as special when they occur in interpolateed variables? For example, I had an array of various codes, some of which began with a +, and I was running through the array, looking for each in a string:
while ($i < $#codearray) {
$code = $codearray[$i];
if ($stringtosearch =~ s/^(\s*)$gramcode//) {
...
last;
}
$i++;
}
I couldn't work out for ages why the codes beginning with + weren't getting found, then I realised Perl was treating them as sepcial characters. I converted the + to \+ in the codes, but is there a better way of doing it? Thanks,
Dom
while ($i < $#codearray) {
$code = $codearray[$i];
if ($stringtosearch =~ s/^(\s*)$gramcode//) {
...
last;
}
$i++;
}
I couldn't work out for ages why the codes beginning with + weren't getting found, then I realised Perl was treating them as sepcial characters. I converted the + to \+ in the codes, but is there a better way of doing it? Thanks,
Dom