How does this look (patch is on top of [id://patchable settings;displaycode|previous patch]):
--- Everything.pm 2004-10-05 11:28:38.716515200 -0700 +++ Everything.pm.new 2004-10-05 11:31:58.093204800 -0700 @@ -261,13 +261,28 @@ sub unescape sub unpackVars { my ($vars) = @_; + my $format_version = "00"; + + # version 00: original format + # version 01: keys are escaped, not just values + $format_version = $1 if $vars =~ s/^==(\d\d)&//; return {} unless $vars; - my %vars = map { split /=/ } split (/&/, $vars); - foreach (keys %vars) { - unescape $vars{$_}; - if ($vars{$_} eq ' ') { $vars{$_} = ""; } + my %vars; + + for (split /&/, $vars) { + my ($k,$v) = split /=/; + + if ($format_version > 0) { + unescape( $k, $v ); + } else { + unescape( $v ); + } + + $v = '' if $v eq ' '; + + $vars{$k} = $v; } return \%vars; @@ -296,7 +311,9 @@ sub packVars $$varsref{$_} = " " unless $$varsref{$_}; } - return join("&", map( $_."=".escape($$varsref{$_}), keys %$varsre +f) ); + # current format version: 01 + return join("&", "==01", + map( escape($_)."=".escape($$varsref{$_}), keys %$varsref) ); } ##################################################################### +########
I think I've placed more emphasis (or at least tried to) on readability and reuse than what you had suggested. I'm guessing it will be about as fast as the existing code. If you are ok with this, I'll try it out on the test server.

In reply to Re^4: patchable settings by ysth
in thread patchable settings by ysth

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.