According to perlretut ( here ):
And perl.com says :The escape sequence \Q ...\E quotes, or protects most non-alphabetic + characters. For instance, 1. $x = "\QThat !^*&%~& cat!"; 2. $x =~ /\Q!^*&%~&\E/; # check for rough language It does not protect $ or @ , so that variables can still be substitute +d.
You cannot include a literal $ or @ within a \Q sequence. An unescaped $ or @ interpolates the corresponding variable, while escaping will cause the literal string \$ to be matched. You'll need to write something like m/\Quser\E\@\Qhost/.So, escaping should work :
So maybe your regex isn't what you think - try a little debugging :use warnings; use strict; print "Yes!\n" if ( '$@' =~ m|\$\@| ); # prints "Yes!"
HTHuse warnings; use strict; my $string = '@@@'; if ( $string =~ m|\$\@| ){ print "Yes!\n"; } else { print "\'$string\' did not match...\n"; } # prints "'@@@' did not match..."
Update: Hmmm... damn slow typing... kennethk may have won the battle, but next time...(or not)!
In reply to Re: regular expression with @@/
by BioLion
in thread regular expression with @@/
by jim_neophyte
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |