App-FTNDB
view release on metacpan or search on metacpan
bin/ftndb-nodelist view on Meta::CPAN
# Find the most recent version (by day number) when given a base name & dir
# of the nodelist; once this is implemented, this will be the default.
# Note that if there is more than one file with the same base name, it will
# use the first one found.
use constant MinusOne => -1;
my ($basename) = @_;
my ( $i, @files );
if ($opt_v) { logging($log_file, $log_id, "Searching for $basename files.") }
opendir DIR, $nodelist_directory;
@files = reverse sort (grep( /$basename\.[0-9][0-9][0-9]$/i, readdir(DIR) ));
closedir DIR;
if ( $#files == MinusOne ) {
logging($log_file, $log_id, "Nodelist files $basename not found");
print "\nNodelist files $basename not found.\n";
HELP_MESSAGE();
exit 0;
}
else {
if ($opt_v) {
for ( $i = 0 ; $i < @files ; $i++ ) {
logging($log_file, $log_id, "Nodelist file $i found: $files[$i]");
}
}
}
if ( $#files > 1 ) {
logging($log_file, $log_id, "More than one '$basename' found, using first.");
}
return ( $files[0] ); # return filename
}
#########################################################################
# Display Version message
#########################################################################
sub VERSION_MESSAGE {
my $fh = shift;
print {$fh} "ftndb-nodelist version $VERSION\n";
return();
}
################################################################################
=head1 CONFIGURATION
Configuration information not provided by the command line options are
obtained from a configuration file. That can be defined by setting the
"-c" option, which is the path and file name of the configuration file
to be used. If that is not defined, it looks for a file named ftndb.cfg
in the current directory. The file contains configuration items listed
outside of a named section as well as those listed within a named section,
and blank lines and lines starting with a "#" are ignored.
The first items in the file are those outside of a named section:
=over 4
=item LogFile
This is the required filename and path of a log file.
=back
The B<Database> section in the configuration file has the following
keywords:
=over 4
=item Type
Database type.
This needs to be a database type for which a DBD module exists, the type
being the name as used in the DBD module. The default type is SQLite.
=item Name
Database name.
For an SQLite database; this needs to be at least the filename and can
also include a path.
=item User
Database user.
For an SQLite database, this defaults to an empty string as it is not
needed for that type of database.
=item Password
Database password.
For an SQLite database, this defaults to an empty string as it is not
needed for that type of database.
=back
The B<Nodelist> section in the configuration file has the following
keywords:
=over 4
=item Directory
The directory where the FTN Nodelist files are located.
=back
This is an example of the contents of an ftndb.cfg file for use with
FTN Nodelist related processing:
# ftndb.cfg
( run in 2.530 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )