App-FTNDB

 view release on metacpan or  search on metacpan

lib/App/FTNDB/Nodelist.pm  view on Meta::CPAN

=cut

sub remove_ftn_domain {

    my($db_handle, $table_name, $domain) = @_;

    my $sql_statement = "DELETE FROM $table_name WHERE domain = '$domain'";

    $db_handle->do("$sql_statement") or croak($DBI::errstr);

    return(0);

}

=head2 nodelist_file_info

Syntax:  %nodelist_info = nodelist_file_info($nodelist_file);

Returns a hash containing the header and other information for a nodelist file
when given the file name and path for an FTN nodelist file. The possible keys
returned in the hash are as follows:

=over 4

=item Year

The four digit year from the nodelist file header line. Defaults to the year
number from the nodelist file time stamp.

=item YearDay

The year day number from the nodelist file header line. Defaults to the file
suffix of the nodelist, which is assumed to be a three digit number.

=item FileYear

The four digit year number from the timestamp of the nodelist file.

=item FileYDay

The year day number from the timestamp of the nodelist file.

=item HeaderLine

The header line (first line) from the nodelist file as a string.

=back

=cut

sub nodelist_file_info {

    my $nodelist_file = shift;

    my (%info, $nl);

    use File::Basename;
    ( $info{'FileName'}, $info{'FileDir'}, $info{'FileSuffix'} ) = fileparse($nodelist_file, qr/[^.]*/);

    use File::stat;
    my $fs = stat($nodelist_file);

    #   year of the converted timestamp is the fifth item
    $info{'FileYear'} = (localtime($fs->mtime))[5] + 1900;
    #   yday of converted timestamp is the seventh item
    $info{'FileYDay'} = (localtime($fs->mtime))[7] + 1;

    # Read in the first line of the nodelist file.
    open $nl, q{<}, $nodelist_file or croak "Cannot open $nodelist_file";
    $info{'HeaderLine'} = <$nl>;
    close $nl;

    #   Year key defaults to the four digit year from the nodelist file timestamp.
    $info{'Year'} = $info{'FileYear'};

    #   YearDay key defaults to the nodelist file suffix.
    $info{'YearDay'} = $info{'FileSuffix'};

    return %info;
}

=head1 EXAMPLES

An example of opening an FTN database, then creating a nodelist table,
loading data to it, then creating an index on it, and the closing
the database:

    use App::FTNDB::Nodelist;

    my $db_handle = open_ftn_database(\%db_option);
    create_nodelist_table($db_handle, $table_name);
    ...   (Load data to nodelist table)
    create_ftnnode_index($db_handle, $table_name);
    close_ftn_database($db_handle);

=head1 AUTHOR

Robert James Clay, C<< <jame at rocasa.us> >>

=head1 BUGS

Please report any bugs or feature requests via the web interface at
L<https://sourceforge.net/p/ftnpl/ftndb/tickets/>. I will be notified,
and then you'll automatically be notified of progress on your bug
as I make changes.

Note that you can also report any bugs or feature requests to
C<bug-ftndb at rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ftndb>;
however, the FTN Database application Issue tracker at the
SourceForge project  is preferred.


=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc App::FTNDB::Nodelist


You can also look for information at:



( run in 2.372 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )