Subject: | read_config and write_config can not be used without exporting |
Because read_config() and write_config() do not live in the Config::Std
namespace they cannot be called without exporting without breaking
encapsulation of the module.
require Config::Std;
Config::Std::read_config(...); # not there, its in Config::Std::Hash
While there's no promise this should work, its a pretty safe assumption
that it will for most modules. Breaking it should be avoided without a
good reason. Simply moving read_config() and write_config() into
Config::Std solves this problem.
As it turns out this refactoring reveals some other minor cleanup
opportunities:
* strict was not turned on. There were a few cases where globals were
accidentaly used.
* The $hash_ref inside read_config() is blessed to Config::Std::Hash but
never used a an object. There is no need for the bless nor for a
separate Config::Std::Hash package.
* Since Config::Std::Hash is no longer a class its package lexicals no
longer need to be Class::Std object attributes.
Subject: | std_strict.patch |
Message body is not shown because it is too large.
Subject: | std_not_a_class.patch |
Mon Apr 10 14:17:07 PDT 2006 schwern@pobox.com
* Config::Std::Hash is not used as a class
$hash_ref is never used as an object, don't bless it.
Config::Std::Hash is never used as an object, no reason for its package
lexicals to be object attributes.
diff -rN old-Config-Std-v0.0.4/lib/Config/Std.pm new-Config-Std-v0.0.4/lib/Config/Std.pm
268d267
< use Class::Std;
273,275c272,274
< my %post_section_gap_for :ATTR;
< my %array_rep_for :ATTR;
< my %filename_for :ATTR;
---
> my %post_section_gap_for;
> my %array_rep_for;
> my %filename_for;
349,350d347
< bless $hash_ref, 'Config::Std::Hash';
<