summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-10-12 00:14:19 +0000
committerfukachan <fukachan>2001-10-12 00:14:19 +0000
commit0d7b3a7ed1b6cbb92a074865bdefa9bfdd3e2d8d (patch)
treee89fe7e6b2d6c28e577fef062f28a2dab4a4b57d
parent90477d5acc3e02b6112ebbea544673efd1cf49f0 (diff)
downloadfml8-0d7b3a7ed1b6cbb92a074865bdefa9bfdd3e2d8d.tar.gz
fml8-0d7b3a7ed1b6cbb92a074865bdefa9bfdd3e2d8d.tar.bz2
fml8-0d7b3a7ed1b6cbb92a074865bdefa9bfdd3e2d8d.zip
expand_variable_in_buffer: expand $varname to $config->{ varname }
-rw-r--r--fml/lib/FML/Config.pm26
1 files changed, 25 insertions, 1 deletions
diff --git a/fml/lib/FML/Config.pm b/fml/lib/FML/Config.pm
index ec022e4a..ce0be180 100644
--- a/fml/lib/FML/Config.pm
+++ b/fml/lib/FML/Config.pm
@@ -1,7 +1,7 @@
#-*- perl -*-
# Copyright (C) 2000-2001 Ken'ichi Fukamachi
#
-# $FML: Config.pm,v 1.41 2001/10/10 03:10:10 fukachan Exp $
+# $FML: Config.pm,v 1.42 2001/10/10 14:53:45 fukachan Exp $
#
package FML::Config;
@@ -491,6 +491,30 @@ sub _expand_variables
}
+=head2 C<expand_variable_in_buffer($rbuf)>
+
+expand $varname to $config->{ varname } in C<$rbuf>.
+
+=cut
+
+# Descriptions: expand $varname to $config->{ varname }
+# Arguments: $config $ref_buffer
+# Side Effects: $ref_buffer is rewritten.
+# Return Value: none
+sub expand_variable_in_buffer
+{
+ my ($config, $rbuf) = @_;
+
+ while ($$rbuf =~ /\$([\w\d\_]+)/) {
+ my $varname = $1;
+ if (defined $config->{ $varname }) {
+ my $x = $config->{ $varname };
+ $$rbuf =~ s/\$$varname/$x/;
+ }
+ }
+}
+
+
=head2 C<yes( key )>
useful method to return 1 or 0 according the value to the given key.