$conf{$1}++;
next;
}
+
+ # command hooks => hasParam => both.
+ # note: this does not support multiple lines.
+ if (/\'Identifier\'[\s\t]=>[\s\t]+\'(\S+?)\'/) {
+# print "File: $file: command hook: $1\n";
+ $both{$1}++;
+ next;
+ }
}
close IN;
}
sub getRandomLineFromFile {
my($file) = @_;
- if (! -f $file) {
- &WARN("gRLfF: file '$file' does not exist.");
+ if (!open(IN, $file)) {
+ &WARN("gRLfF: could not open ($file): $!");
return;
}
- if (open(IN,$file)) {
- my @lines = <IN>;
+ my @lines = <IN>;
+ close IN;
- if (!scalar @lines) {
- &ERROR("GRLF: nothing loaded?");
- return;
- }
+ if (!scalar @lines) {
+ &ERROR("GRLF: nothing loaded?");
+ return;
+ }
- while (my $line = &getRandom(@lines)) {
- chop $line;
+ # could we use the filehandler instead and put it through getRandom?
+ while (my $line = &getRandom(@lines)) {
+ chop $line;
- next if ($line =~ /^\#/);
- next if ($line =~ /^\s*$/);
+ next if ($line =~ /^\#/);
+ next if ($line =~ /^\s*$/);
- return $line;
- }
- } else {
- &WARN("gRLfF: Could not open file ($file): $!");
- return;
+ return $line;
}
}