in reply to Of the meaning of 'our'
Well, our can be used in the way you mention. It can also be used very much like use vars is used. However, using our like use vars is a bad idea (see Why is 'our' good?).
So, if I wasn't worried about supporting pre-5.6 Perl, I might write code like:
but probably only if %OPT needed to be global, that is accessible outside the scope of this file. Otherwise I'd just use:use strict; package A; { our %OPT= ( fred => 1, barney => 2, ); } sub getopts { our %OPT; # ... }
- tye (but my friends call me "Tye")my %OPT= ( ... ); sub getopts { # Global( =%OPT );
|
|---|