in reply to Re^2: patchable settings
in thread patchable settings
I don't understand why people are reluctant to use techniques like version codes here. (I say this because ive noticed others also dislike version codes.) To me a settings field is just a data format which is really a file format. And its usually better to code version strings into such systems early while its easy. The flexibility such a mechanism offers in a situation like here is quite nice if you ever have reason to change the way things work. And I've had call to use it elsewhere on PM to good effect already.
# note that these two vars go together to a certain extent. my $magic="===&01"; my $escape="%=&"; sub unpack_hash { my ($str)=shift; my %hash; if (substr($str,0,6) eq $magic) { substr($str,0,6)=''; %hash=map { map { s/%(\d)/substr($escape,$1,1)/ge; $_ } split /=/,$_ } split /&/,$str; } else { # old getVars() support... } } sub pack_hash { my $hash=shift; return $magic.join("&",map { join "=",map { (my $v=$_)=~s/([$escape])/'%'.index($escape,$1)/ge $v } $_ => $hash{$_} } sort keys %$hash); }
Since bullet proofing getVars() probably means it faster to do than the current method, I personally dont see why we shouldn't do it.
First they ignore you, then they laugh at you, then they fight you, then you win.
-- Gandhi
• Update:
Note that only a sliver of extra code would allow using Data::Dumper for the values if requested to do so (with only a tiny overhead were the hash values reference free). Ultimately that would be where I would go. Encode the keys with extra info when packed to indicate their value needs thawing. Anyway.... :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: patchable settings
by ysth (Canon) on Sep 28, 2004 at 07:42 UTC | |
by demerphq (Chancellor) on Sep 28, 2004 at 07:57 UTC | |
by ysth (Canon) on Sep 28, 2004 at 08:55 UTC | |
|
Re^4: patchable settings
by ysth (Canon) on Oct 05, 2004 at 19:03 UTC | |
by demerphq (Chancellor) on Oct 06, 2004 at 09:20 UTC | |
by ysth (Canon) on Oct 06, 2004 at 18:11 UTC |