Mailing List Archive

local($)) causes spurious warning?
Test script:

--- cut ---
#!perl -w
print "Diagnostic: my gid '$)'\n";
&test();
exit 0;

sub test {
local($));
return 1;
}
--- cut ---

test run:
--- cut ---
Diagnostic: my gid '10 200 5 10'
Argument "10 200 5 10" isn't numeric for return at bugtest line 3.
--- cut ---

I guess localising $) doesn't work, but the error message sure confused
me until I managed to track down where the argument was coming from.
Note especially the line number given for the error (ie the line number
of the call to &test rather than of the return statement itself).

Separate question: is there an easy way to establish from the docs
which magic variables can be preserved by localising?

Hugo van der Sanden
Re: local($)) causes spurious warning? [ In reply to ]
In message <9511011118.AA01196@gold.compulink.co.uk>, I wrote:
:Test script:
:
:--- cut ---
:#!perl -w
:print "Diagnostic: my gid '$)'\n";
:&test();
:exit 0;
:
:sub test {
: local($));
: return 1;
:}
:--- cut ---

Further investigation implies that $) can only have a numeric assigned
to it, so any method of restoring will fail. Test script:

#!perl -w
$) = $(; # fails with warning message if $( is a list of groups

I'm running this under SunOS 4.1.3_U1, and I've found it to fail in the
same way under Solaris 2.4.

Hugo van der Sanden