in reply to In string, @var now must (NOT) be written as \@var

I'm a bit confused about this post. I am running Perl 5.6.0 and I still get the error message you describe. What version of Perl are you running?

I am wondering if there is something on *your* system that is suppressing the error (such as a globally defined array matching what's in the interpolated string). For example, this will throw an exception:

#!/usr/bin/perl use strict; print "This is dev@null.com";

Perl sees this as a problem because it cannot interpolate @null. However, if @null is already defined, it's interpolated and no error is generated:

#!/usr/bin/perl use strict; my @null = qw/ 1 2 3/; print "This is dev@null.com";

Is one of the modules you have on your system exporting an array with the name of your host? That would suppress it. Further, since you know it needs to be escaped, why not just escape it or use single quotes to suppress interpolation?

Cheers,
Ovid

Vote for paco!

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
Re:x2 In string, @var now must (NOT) be written as \@var
by grinder (Bishop) on Aug 03, 2001 at 01:05 UTC
    Ovid, this is behaviour appears in 5.6.1.

    % perl -v This is perl, v5.6.0 built for i386-openbsd [...] % perl -lwe 'print q{foo@bar.com}' foo@bar.com % perl -lwe 'print qq{foo@bar.com}' In string, @bar now must be written as \@bar at -e line 1, near "foo@b +ar" Execution of -e aborted due to compilation errors. --versus-- % perl -v This is perl, v5.6.1 built for i686-linux % perl -lwe 'print q{foo@bar.com}' foo@bar.com % perl -lwe 'print qq{foo@bar.com}' Possible unintended interpolation of @bar in string at -e line 1. Name "main::bar" used only once: possible typo at -e line 1. foo.com

    The error messages change when you use strict, of course, but you get the idea. By the way, if you have the time, upgrading to 5.6.1 is recommended. There are a lot of POD tweaks, test tweaks, leak removals, B::* improvements and all sort of assorted corrections between the two.

    --
    g r i n d e r