error with variable

  • Thread starter nicolas-laurent
  • Start date
N

nicolas-laurent

New to programming, I don't see what wrong with this code. The script
run on /fr/rules/sens1 but not on en/rules/sens1. I suspect something
wrong with
readParams(\$lang);


# ---------------MAIN
BEGIN-------------------------------------------------
my $lang;
readParams(\$lang);
#\$silent, \@rulesFiles, \$base);
printc "lang = ", 'black', ''; printc "$lang", 'green';
my $WORD = "[[:alpha:]'-]";
my @RULES_FILES;

my $exceptFile = "$lang/config/exceptions.txt";
buildRulesSens(1, $exceptFile, $lang);
#buildRulesSens(2, $configFile, $lang);

# -------------------------------------------------------------------
sub buildRulesSens {
my ($sens, $exceptFile, $lang) = @_;

@RULES_FILES = ();
my $rulesPath = "$lang/rules/sens$sens";
find \&lsRuleFiles, "$rulesPath";
my $out = "$lang/rules_sens$sens.txt";

my $conf = readConfFile($exceptFile);

open (OUT, ">$out") or error("Cant open '$out'");
foreach my $ruleF (@RULES_FILES) {
printc "Processing rules file: $ruleF\n";
print OUT "#<FILE>$ruleF<BODY>\n";
my $newRules = buildRules($ruleF, $conf);
foreach my $r (@$newRules) {
print OUT "$r\n";
}
#trc('_rules', $_rules); die;
}
close OUT;
}


# -------------------------------------------------------------------




CODE


sub readParams {
my ($lang) = @_;
my ($help, $version);

GetOptions(
"--lang:s" => $lang,
"v" => \$version, "version" => \$version,
"h" => \$help, "help" => \$help);

error("--lang parameter missing") unless $$lang;
if ($$lang !~ /(fr|en)/) {
error("Invalid value for parameter lang=$$lang");
}
}
 
T

Tad McClellan

nicolas-laurent said:
I don't see what wrong with this code.

printc "lang = ", 'black', ''; printc "$lang", 'green';


Perl does not have a printc() function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top