NAME
Math::OEIS::Names - read the OEIS names file
SYNOPSIS
use Math::OEIS::Names;
my $name = Math::OEIS::Names->anum_to_name('A123456');
DESCRIPTION
This is an interface to the OEIS names file. The file should be downloaded and unzipped to ~/OEIS/names,
cd ~/OEIS
wget http://oeis.org/names.gz
gunzip names.gz
names is a very large file listing each A-number and the sequence name. The name is a single line description, sometimes a slightly long line.
The names file is sorted by A-number so anum_to_name()
is a text file binary search (currently implemented with Search::Dict).
Terms of use for the names file data can be found at (Creative Commons Attribution Non-Commercial 3.0 at the time of writing)
FUNCTIONS
$name = Math::OEIS::Names->anum_to_name($anum)
-
For a given
$anum
string such as "A000001", return the sequence name as a string, or if not found then returnundef
.The returned
$name
may contain non-ASCII characters. In Perl 5.8 up, they're returned as Perl wide chars. In earlier Perl,$name
is the native encoding of the names file (which is UTF-8).If running in
perl -T
taint mode then$name
is tainted in the usual way for reading from a file. Math::OEIS::Names->close()
-
Close the names file, or do nothing if already closed or never opened.
Oopery
$obj = Math::OEIS::Names->new (key => value, ...)
-
Create and return a new
Math::OEIS::Names
object to read an OEIS "names" file. The optional key/value parameters arefilename => $filename default ~/OEIS/names fh => $filehandle
The default file is per
default_filename()
below. A different filename can be given or an open filehandlefh
. Forfh
, thefilename
option is used in diagnostics if present. $name = $obj->anum_to_name($anum)
-
For a given
$anum
string such as "A000001", return the sequence name as a string, or if not found then returnundef
. $filename = $obj->filename()
-
Return the names filename from a given
$obj
object. This is thefilename
parameter if given, or the filename which was determined bydefault_filename()
otherwise. $filename = Math::OEIS::Names->default_filename()
$filename = $obj->default_filename()
-
Return the default filename which is used if no
filename
orfh
option is given. This is names found sought inMath::OEIS->local_directories()
. $obj->close()
-
Close the file handle, or do nothing if already closed.
($anum,$str) = Math::OEIS::Names->line_split($line)
-
Split a line from the names file into A-number and text.
$line
should be likeA123456 some descriptive text
Any trailing newline on
$line
is stripped.If
$line
is not an A-number and text like this then return an empty list. The names file starts with some comment lines (#
) and they get this empty return.
SEE ALSO
Math::OEIS
, Math::OEIS::Stripped
OEIS files page http://oeis.org/allfiles.html
HOME PAGE
http://user42.tuxfamily.org/math-oeis/index.html
LICENSE
Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Kevin Ryde
Math-OEIS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-OEIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-OEIS. If not, see http://www.gnu.org/licenses/.