perl -e 'if ("h@t" =~ /(\@)/ ) { print $1 }'"h@t" looks to Perl like you're trying to interpolate the array @t (the previous case doesn't because the quote ends the string early.
perl -e 'if ("h\@t" =~ /(\@)/ ) { print $1 }'
or
perl -e 'if (\'h@t\' =~ /(\@)/ ) { print $1 }'
should work fine.
Update: err, ooops :-)
-David
In reply to Re: Matching @ in string
by erroneousBollock
in thread Matching @ in string
by loris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |