Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Strict isn't strict enough (stop it)

by tobyink (Abbot)
on Dec 31, 2011 at 19:50 UTC ( #945762=note: print w/ replies, xml ) Need Help??


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


Comment on Re^2: Strict isn't strict enough (stop it)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://945762]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2015-07-05 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls