Great Circle Associates Majordomo-Users
(April 1995)
 

Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: Re: domo with Perl 5
From: Brian Clapper <bmc @ telebase . com>
Date: Tue, 18 Apr 1995 12:17:39 -0400
To: majordomo-users @ GreatCircle . COM
In-reply-to: <199504181455.JAA13591@usis.com> (siberia@usis.com)

>>>>> "Kimberly" == Kimberly Long <siberia@usis.com> writes:

Kimberly> I've finally figured out what caused domo to crash while I was
Kimberly> gone.  It seems my admin upgraded to Perl 5 without me knowing.
Kimberly> Now, how to fix it is the problem.  The faq says:

Kimberly>   Majordomo is written in Perl (at least 4.035, preferably
Kimberly> 4.036). It is also known to work under Perl 5, if you edit
Kimberly> majordomo and resend and look for instances of the "@" character
Kimberly> inside text strings "@" Change the "@" to "\@". This only
Kimberly> happened with recent versions of Perl 5.  The same fix is also
Kimberly> required if you want to run Majordomo under OSF/1 on the DEC AXP
Kimberly> systems with Perl 4 or 5. [from Jim Reisert]

Kimberly> I'm not really clear on this explanation.  Do I change every
Kimberly> single "@" to "\@"?

Only those that appear within quotations.  "@" introduces an array
reference in perl.  Pre-5.0 versions of perl ignored the special meaning of
"@" when the "@" character appeared *within* a text string, such as this:

        print STDERR, "Can't send to $user@$host.\n";

Perl 5 will interpret that "@" sign as an array interpolation.  For
example, run the following script through perl 4:

        $user = "bmc";
        $host = "telebase.com";
        print STDERR, "Can't send to $user@$host.\n";

You should see the message "Can't send to bmc@telebase.com."  Run it
through perl 5, however, and the message becomes: "Can't send to bmc.".
Perl 5 has interpreted the "@" differently.  It looks at the "@$host" part
and says, "Okay, first substitute '$host'.  That gets us '@telebase.com'
Now, interpolate the values of perl array '@telebase.com'.  Oops!  That
array doesn't exist, so we'll have to substitute the empty string."

You can verify this behavior by doing the following:

        $var1  = "variable 1";
        $var2  = "array";
        @array = ("element-1", "element-2");

        print "$var1 @$var2\n";

If you run that script through perl 4, you should see the output:

        variable 1 @array

Again, that's because the "@" inside the quotes is treated as a literal in
perl 4.  If you run that same script through perl 5, you should see the
output:

        variable 1 element-1 element-2

To get a literal "@" to appear in perl 4, escape its meaning with a
preceding backslash.  That solution should fix things for perl 5 without
screwing up the script for perl 4.

Sorry for the long explanation, and for boring the perl experts ...

----
Brian M. Clapper, bmc@telebase.com
The end move in politics is always to pick up a gun.
        -- Buckminster Fuller


References:
Indexed By Date Previous: Looking for pre-compiled wrapper for SCO Unix.
From: Jonathan Young <jyoung@unitedmedia.com>
Next: Re: domo with Perl 5
From: dwolfe@risc.sps.mot.com (Dave Wolfe)
Indexed By Thread Previous: domo with Perl 5
From: "Kimberly Long" <siberia@usis.com>
Next: Re: domo with Perl 5
From: dwolfe@risc.sps.mot.com (Dave Wolfe)

Google
 
Search Internet Search www.greatcircle.com