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__ Data::Section::Seekable v1 part1,0,14 part2,14,17,important This is part1 This is part two
This class lets you read parts from __DATA__ section. Data section should contain data in the format described by Data::Section::Seekable.
Constructor. Attributes:
handle => filehandle (default: DATA)
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.
Return list of all known parts in the data section, sorted lexicographically.
Read the content of a part named $name. Will die if part is unknown.
$name
Read the extra information field (the fourth field of TOC line) of a part named $name. Will die if part is unknown.
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 https://metacpan.org/release/Data-Section-Seekable.
Source repository is at https://github.com/perlancar/perl-Data-Section-Seekable.
Data::Section::Seekable for the description of the data format.
Data::Section::Seekable::Writer to generate the data section.
perlancar <perlancar@cpan.org>
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 <perlancar@cpan.org>.
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 https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Section-Seekable
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.
To install Data::Section::Seekable, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Section::Seekable
CPAN shell
perl -MCPAN -e shell install Data::Section::Seekable
For more information on module installation, please visit the detailed CPAN module installation guide.