Data::Section::Seekable::Reader - Read parts from data section


This document describes version 0.092 of Data::Section::Seekable::Reader (from Perl distribution Data-Section-Seekable), released on 2023-03-24.


In your script:

 use Data::Section::Seekable::Reader;

 my $reader = Data::Section::Seekable::Reader->new;

 my $p2 = $reader->read_part('part2'); # -> "This is part\ntwo\n"
 my $p1 = $reader->read_part('part1'); # -> "This is part1\n"
 my $p3 = $reader->read_part('part3'); # dies, unknown part

 my $e1 = $reader->read_extra('part1'); # -> undef
 my $e2 = $reader->read_extra('part2'); # -> "important"
 my $e3 = $reader->read_extra('part3'); # dies, unknown part

 Data::Section::Seekable v1

 This is part1
 This is part


This class lets you read parts from __DATA__ section. Data section should contain data in the format described by Data::Section::Seekable.


new(%attrs) => obj

Constructor. Attributes:

  • handle => filehandle (default: DATA)

    To access another package's data section, you can do:

     my $reader = Data::Section::Seekable::Reader->new(handle => \*Another::Package::DATA);

The constructor will also read the header and TOC in the data section. Will die on failure.

$reader->parts($name) => list

Return list of all known parts in the data section, sorted lexicographically.

$reader->read_part($name) => str

Read the content of a part named $name. Will die if part is unknown.

$reader->read_extra($name) => str

Read the extra information field (the fourth field of TOC line) of a part named $name. Will die if part is unknown.


Why am I getting the error message "readline() on unopened filehandle DATA at ..."?

You are probably reading in the BEGIN phase, at which point the DATA filehandle is not available. Read perldata for more details.


Please visit the project's homepage at


Source repository is at


Data::Section::Seekable for the description of the data format.

Data::Section::Seekable::Writer to generate the data section.


perlancar <>


To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

 % prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.


This software is copyright (c) 2023, 2016, 2015 by perlancar <>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.