diff options
author | Tom Phoenix <rootbeer@teleport.com> | 1996-12-30 09:24:16 -0800 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1997-01-01 08:59:00 +1200 |
commit | aa1bdcb8033d23da72755eda19a512411642de03 (patch) | |
tree | a7c3d7013f9fea8e836eb75ee5f727d9e73fc682 /configpm | |
parent | 3524d3b9766c150548bbd837b65d78ef993d647d (diff) | |
download | perl-aa1bdcb8033d23da72755eda19a512411642de03.tar.gz |
Improving Config.pm
private-msgid: <Pine.GSO.3.95.961230091244.13467L-100000@solaris.teleport.co
Diffstat (limited to 'configpm')
-rwxr-xr-x | configpm | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -86,11 +86,20 @@ EOT print CONFIG <<'ENDOFEND'; sub FETCH { - # check for cached value (which maybe undef so we use exists not defined) + # check for cached value (which may be undef so we use exists not defined) return $_[0]->{$_[1]} if (exists $_[0]->{$_[1]}); - - my($value); # search for the item in the big $config_sh string - return undef unless (($value) = $config_sh =~ m/^$_[1]='(.*)'\s*$/m); + + # Search for it in the big string + my($value, $start, $marker); + $marker = "$_[1]='"; + # return undef unless (($value) = $config_sh =~ m/^$_[1]='(.*)'\s*$/m); + $start = index($config_sh, "\n$marker"); + return undef if ( ($start == -1) && # in case it's first + (substr($config_sh, 0, length($marker)) ne $marker) ); + if ($start == -1) { $start = length($marker) } + else { $start += length($marker) + 1 } + $value = substr($config_sh, $start, + index($config_sh, q('), $start) - $start); $value = undef if $value eq 'undef'; # So we can say "if $Config{'foo'}". $_[0]->{$_[1]} = $value; # cache it @@ -101,8 +110,9 @@ my $prevpos = 0; sub FIRSTKEY { $prevpos = 0; - my($key) = $config_sh =~ m/^(.*?)=/; - $key; + # my($key) = $config_sh =~ m/^(.*?)=/; + substr($config_sh, 0, index($config_sh, '=') ); + # $key; } sub NEXTKEY { @@ -113,7 +123,10 @@ sub NEXTKEY { } sub EXISTS { - exists($_[0]->{$_[1]}) or $config_sh =~ m/^$_[1]=/m; + # exists($_[0]->{$_[1]}) or $config_sh =~ m/^$_[1]=/m; + exists($_[0]->{$_[1]}) or + index($config_sh, "\n$_[1]='") != -1 or + substr($config_sh, 0, length($_[1])+2) eq "$_[1]='"; } sub STORE { die "\%Config::Config is read-only\n" } |