in reply to Matching @ in string

I'm suspecting because perl interprets @t within the string h@t as the array @t, since double quotes ("") will cause variables to be interpolated. Inserting both tests into a short script:

#!/usr/bin/perl use strict; use warnings; if ("h@" =~ /(\@)/ ) { print $1 } if ("h@t" =~ /(\@)/ ) { print $1 }

produces:

Possible unintended interpolation of @t in string at ./scratch.pl line + 6. Global symbol "@t" requires explicit package name at ./scratch.pl line + 6. Execution of ./scratch.pl aborted due to compilation errors.

Doing:

#!/usr/bin/perl use strict; use warnings; if ('h@' =~ /(\@)/ ) { print $1 } if ('h@t' =~ /(\@)/ ) { print $1 }

produces:

@@

As expected. HTH.