Problems? Is your data what you think it is? | |
PerlMonks |
Re: Regex error when [] occurs in file..by moritz (Cardinal) |
on Mar 03, 2008 at 15:38 UTC ( [id://671666]=note: print w/replies, xml ) | Need Help?? |
That's what's causing the problem: $' can contain arbitrary data, but you try to treat it as a regex. The "good" solution is to use this regex instead: $temp =~ s/#.*$//; In general you can also quote interpolated variables, then they are treated as text, not as regexes:
If you're not inside a regex, quotemeta does the same job.
In Section
Seekers of Perl Wisdom
|
|