Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 wandering the Monastery: (4)
As of 2014-07-13 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (249 votes), past polls