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

One of the recent releases of perl made it so referring to an undefined array in a string (eg: "Email me at user@host.com") no longer produce the error:

In string, @host now must be written as \@host.

I think that's great, however, while I no longer get that error locally, I get it when I upload scripts to client servers.

So my question is, is there anything I can turn on to get this error again locally?

Note: Upgrading isn't an option. Some of the clients are hosted with companies like AT&T (who runs 5.00404) and have one year contracts. So, aside from running an old version of perl locally, I'm all out of ideas. Anyone have any suggestions?

Replies are listed 'Best First'.
(Ovid) Re: In string, @var now must (NOT) be written as \@var
by Ovid (Cardinal) on Aug 02, 2001 at 22:37 UTC

    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.

      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
Re: In string, @var now must (NOT) be written as \@var
by dragonchild (Archbishop) on Aug 02, 2001 at 22:30 UTC
    Ummm... this may sound like a stupid suggestion, but just put the backslash in? Or, use qq() or '' or any number of other options. Using "" for your string delimiters, irregardless of what the string contains, isn't the brightest thing in the world, not when we have so many other, better, options.
Re: In string, @var now must (NOT) be written as \@var
by trantor (Chaplain) on Aug 02, 2001 at 22:50 UTC

    My reply is a bit off topic, as it's more about testing than coding...

    Anyway, especially when dealing with important clients with specific requirements (e.g. Perl can't be upgraded), you must have very good and compelling reasons NOT to develop and test under the same conditions.

    Infact the difference in @ behaviour might be just one of the subtle differences, and you might realize this when you don't have time to do something about it.

    Besides, my Perl 5.6.1 (GNU/Linux glibc 2.1) interpolates even if the array is undefined and does not print a literal @ unless I quote it.

    If you have good reasons to keep on using a newer Perl (what about modules by the way? differences in versions can affect your development and testing even more!), it's a good idea to check the relevant perldelta manpages, just in case.

    -- TMTOWTDI

Re: In string, @var now must (NOT) be written as \@var
by tachyon (Chancellor) on Aug 02, 2001 at 23:10 UTC

    Yes, get an old version of perl, install it somewhere like usr/bin/perl/V5.004 and use this in the shebang line.

    Having old versions of Perl available for testing/development (like the version on your clients server) makes good logical sense. In fact developing the code using this version of perl makes sense given that Perl aims for backwards compatibility ie 5.004 should run on 5.6 but not necessarily vice versa.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: In string, @var now must (NOT) be written as \@var (boo)
by boo_radley (Parson) on Aug 02, 2001 at 23:37 UTC
    I thought this was done for one of the 5.7.x versions. That is, a development version. I remember the change being talked about in P5P, but I can't find the appropriate digest...
    What's your version?