in reply to Re: Strict isn't strict enough (stop it)
in thread Strict isn't strict enough

An alternative to having Slave.pm export the variable would be to write a get/set wrapper for $Slave::type:

package Slave; my $type; sub type(;$) { $type = shift if @_; $type } 1; package main; use strict; use Slave; Slave::type("FOO"); print Slave::type . "\n"; Slave::tpye("BAR"); # dies

Or, if you're on Perl 5.6+ and don't care about supporting archaic versions of Perl (and you should rarely care about such things)...

package Slave; my $type; sub type(;$) :lvalue { $type = shift if @_; $type } 1; package main; use strict; use Slave; Slave::type = "FOO"; print Slave::type . "\n"; Slave::tpye = "BAR"; # dies