On Mon, 28 Jul 1997 15:35:46 -0400 (EDT), Thomas Lowery
<nab2337@dsacnhp1.dsac.dla.mil> wrote:
>
>Following an example from the perldoc Shell produces the following
>warning messages. How do I avoid the warning?
>
>Variable "$cmd" will not stay shared at (eval 1) line 14.
>Variable "$cmd" will not stay shared at (eval 2) line 14.
Under 5.004, Shell.pm triggers this warning for every sub it autoloads. I
didn't see any response to this message, so here is a simple patch. It just
makes the named sub an anonymous sub assigned to a glob, suppressing the
warning.
Credited: Andrew Pimlott <andrew@pimlott.student.harvard.edu>
p5p-msgid:
199708061739.NAA14754@pimlott.student.harvard.edu
private-msgid: Pine.SOL.3.91.
970806173903.7320H-100000@abel
my $cmd = $AUTOLOAD;
$cmd =~ s/^.*:://;
eval qq {
- sub $AUTOLOAD {
+ *{"$AUTOLOAD"} = sub {
if (\@_ < 1) {
`$cmd`;
}