[Commits] Rev 59: Read config file via "require". Variables have to be in the right scope, in file:///Users/hakan/work/monty_program/mariadb-tools/

Hakan Kuecuekyilmaz hakan.kuecuekyilmaz at t-online.de
Tue Nov 2 01:47:27 EET 2010


At file:///Users/hakan/work/monty_program/mariadb-tools/

------------------------------------------------------------
revno: 59
revision-id: hakan at askmonty.org-20101101234727-388xcwwwute562no
parent: hakan at askmonty.org-20101101234633-7ndor5494aqrwa78
committer: Hakan Kuecuekyilmaz <hakan at askmonty.org>
branch nick: mariadb-tools
timestamp: Tue 2010-11-02 00:47:27 +0100
message:
  Read config file via "require". Variables have to be in the right scope,
  therefore we use "our".
-------------- next part --------------
=== modified file 'sql-bench/conf/sql-bench-base.cnf'
--- a/sql-bench/conf/sql-bench-base.cnf	2010-10-28 16:18:49 +0000
+++ b/sql-bench/conf/sql-bench-base.cnf	2010-11-01 23:47:27 +0000
@@ -115,3 +115,6 @@
   mysqld_init_command => '',
   sql_bench_options => '--comment="engine=pbxt-index-cache-size=64M --pbxt-record-cache-size=name=196M"',
 };
+
+# This has to be the last line. See "perldoc -f require" for details.
+1;

=== modified file 'sql-bench/run-sql-bench.pl'
--- a/sql-bench/run-sql-bench.pl	2010-10-28 16:18:49 +0000
+++ b/sql-bench/run-sql-bench.pl	2010-11-01 23:47:27 +0000
@@ -10,7 +10,12 @@
 # Hakan Kuecuekyilmaz, <hakan at askmonty dot org>, 2010-10-22.
 
 use strict;
-my($config, $config_text, $sql_bench_test);
+
+our ($config);
+our ($sql_bench_test);
+
+# Config file we read.
+# TODO: Make the config file a parameter.
 my $config_file = './conf/sql-bench-base.cnf';
 
 my $run_by = qx(whoami);
@@ -23,6 +28,7 @@
 }
 
 # TODO: rewrite to Perl syntax
+# @see perldoc Getopt::Long
 #if ($# != 2) {
 #    echo '[ERROR]: Please provide exactly two options.'
 #    echo "  Example: $0 [/path/to/bzr/repository] [name_without_spaces]"
@@ -34,29 +40,14 @@
 #    SUFFIX="-$2"
 #}
 
-open(CONF, $config_file) or die "unable to open config file '$config_file': $!";
-read(CONF, my $config_text, -s $config_file);
-eval ($config_text);
-
-# Print a specific error if the config file is invalid,
-# along with a line number.
-die "Unable to load $config_file: $@" if $@;
-
-# Here we will have $config->{hash_key1} containing 'hash_value1'.
-# print $config->{configure_env};
-# print "\n";
-# print "\n";
-
-# print $sql_bench_test['myisam']->{'mysqld_start_options'};
-# print "\n";
-# print "\n";
+require $config_file;
 
 #
 # For debugging the config file parsing.
 #
-foreach my $key (keys %{$config}) {
-    print "The value of $key is $config->{$key}\n";
-}
+#foreach my $key (keys %{$config}) {
+#    print "The value of $key is $config->{$key}\n";
+#}
 
 print "\n";
 



More information about the commits mailing list