From: Andrew Pimlott Date: Wed, 6 Aug 1997 01:27:23 +0000 (+1200) Subject: Warning from calls using "use Shell" X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a5bda13b0ef005fbbd13265a362caff51359bbc6;p=p5sagit%2Fp5-mst-13.2.git Warning from calls using "use Shell" On Mon, 28 Jul 1997 15:35:46 -0400 (EDT), Thomas Lowery 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 p5p-msgid: 199708061739.NAA14754@pimlott.student.harvard.edu private-msgid: Pine.SOL.3.91.970806173903.7320H-100000@abel --- diff --git a/lib/Shell.pm b/lib/Shell.pm index bb44b53..1986b52 100644 --- a/lib/Shell.pm +++ b/lib/Shell.pm @@ -21,7 +21,7 @@ AUTOLOAD { my $cmd = $AUTOLOAD; $cmd =~ s/^.*:://; eval qq { - sub $AUTOLOAD { + *{"$AUTOLOAD"} = sub { if (\@_ < 1) { `$cmd`; }