Index: trunk/FACT++/src/rootifysql.cc
===================================================================
--- trunk/FACT++/src/rootifysql.cc	(revision 19116)
+++ trunk/FACT++/src/rootifysql.cc	(revision 19117)
@@ -42,4 +42,5 @@
         ("var.*",         var<string>(),               "Predefined SQL user variables (@VAR)")
         ("env.*",         vars<string>(),              "Predefined environment for substitutions in the query ($ENV)")
+        ("list.*",        var<string>(),               "Predefined environment for substitutions in the query ($ENV). The list is read from the given file (one list entry per line)")
         ("verbose,v",     var<uint16_t>(1),            "Verbosity (0: quiet, 1: default, 2: more, 3, ...)")
         ;
@@ -90,5 +91,7 @@
         "If you specifiy one environmentvariable more than once, a list is created. "
         "For example --env.TEST=1 --env.TEST=2 --env.TEST=3 would substitute "
-        "$TEST or ${TEST} by '1, 2, 3'. This is useful for the SQL `IN` keyword.\n"
+        "$TEST or ${TEST} by '1, 2, 3'. This is useful for the SQL `IN` keyword. "
+        "You can also read the values for an enviroment substitution from a file "
+        "(one element per line), e.g. --env.TEST=file.txt\n"
         "\n"
         "Comments in the query-file can be placed according to the SQL standard inline "
@@ -402,5 +405,5 @@
         if (!fin)
         {
-            cerr << "Could not open '" << file << "': " << strerror(errno) << endl;
+            cerr << "Could not open query in '" << file << "': " << strerror(errno) << endl;
             return 1;
         }
@@ -416,15 +419,30 @@
     // -------------------------------------------------------------------------
 
-    const auto envs = conf.GetWildcardOptions("env.*");
+    map<string, vector<string>> envs;
+    for (const auto &env : conf.GetWildcardOptions("env.*"))
+        envs.emplace(env.substr(4), conf.Vec<string>(env));
+
+    for (const auto &env : conf.GetWildcardOptions("list.*"))
+    {
+        const string fname = conf.Get<string>(env);
+
+        ifstream fin(fname);
+        if (!fin)
+        {
+            cerr << "Could not open environment in '" << fname << "': " << strerror(errno) << endl;
+            return 3;
+        }
+
+        const string &ident = env.substr(5);
+
+        string repl;
+        for (string line; getline(fin, line); )
+            envs[ident].push_back(line);
+    }
 
     for (const auto &env : envs)
     {
-        regex r1("\\$\\{"+env.substr(4)+"\\}");
-        regex r2("\\$"+env.substr(4)+"\\b");
-
-        const string repl = boost::join(conf.Vec<string>(env), ", ");
-
-        query = regex_replace(query, r1, repl);
-        query = regex_replace(query, r2, repl);
+        regex rexpr("\\$\\{"+env.first+"\\}|\\$"+env.first+"\\b");
+        query = regex_replace(query, rexpr, boost::join(env.second, ", "));
     }
 
