Math::OEIS::Names - read the OEIS names file


 use Math::OEIS::Names;
 my $name = Math::OEIS::Names->anum_to_name('A123456');


This is an interface to the OEIS names file. The file should be downloaded and unzipped to ~/OEIS/names,

    cd ~/OEIS
    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)


$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 return undef.

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.


Close the names file, or do nothing if already closed or never opened.


$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 are

    filename => $filename         default ~/OEIS/names
    fh       => $filehandle

The default file is per default_filename() below. A different filename can be given or an open filehandle fh. For fh, its filename can be given too and might be used in diagnostics.

$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 return undef.

$filename = $obj->filename()

Return the names filename from a given $obj object. This is the filename parameter if given, or filename which was determined by default_filename() otherwise.

$filename = Math::OEIS::Names->default_filename()
$filename = $obj->default_filename()

Return the default filename which is used if no filename or fh option is given. The file is names in Math::OEIS->local_directories().


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 like

    A123456 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.


Math::OEIS, Math::OEIS::Stripped

OEIS files page



Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 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