kael has asked for the wisdom of the Perl Monks concerning the following question:

ok, this is what I have
$prompt=color("blue").": ".color("reset"); unless ($line=~/\r\n$prompt$/){ $line.="\r\n$prompt"; }
This is with the Term::ANSIColor module...
The problem is this crashes complaining about an umatched []
I tried using /o but that didn't help. Why isn't whats in the variable getting escaped out and how can I tell it to get escaped?

Replies are listed 'Best First'.
Re: Reg exp with ansi
by chipmunk (Parson) on Jan 08, 2001 at 23:41 UTC
    The value of an interpolated variable in a regex is not supposed to be escaped automatically; it would be impossible to use strings as regexes that way. Instead, you can ask for the escaping when you need it, with quotemeta or \Q: unless ($line =~ /\r\n\Q$prompt\E$/) {