.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Data::Section::Simple 3" .TH Data::Section::Simple 3 2023-07-20 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Data::Section::Simple \- Read data from _\|_DATA_\|_ .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Data::Section::Simple qw(get_data_section); \& \& # Functional interface \-\- reads from caller package _\|_DATA_\|_ \& my $all = get_data_section; # All data in hash reference \& my $foo = get_data_section(\*(Aqfoo.html\*(Aq); \& \& # OO \- allows reading from other packages \& my $reader = Data::Section::Simple\->new($package); \& my $all = $reader\->get_data_section; \& \& _\|_DATA_\|_ \& \& @@ foo.html \& \& Hello \& \& \& @@ bar.tt \& [% IF true %] \& Foo \& [% END %] .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Data::Section::Simple is a simple module to extract data from \&\f(CW\*(C`_\|_DATA_\|_\*(C'\fR section of the file. .SH LIMITATIONS .IX Header "LIMITATIONS" As the name suggests, this module is a simpler version of the excellent Data::Section. If you want more functionalities such as merging data sections or changing header patterns, use Data::Section instead. .PP This module does not implement caching (yet) which means in every \&\f(CW\*(C`get_data_section\*(C'\fR or \f(CWget_data_section($name)\fR this module seeks and re-reads the data section. If you want to avoid doing so for the better performance, you should implement caching in your own caller code. .SH BUGS .IX Header "BUGS" .SS "_\|_DATA_\|_ appearing elsewhere" .IX Subsection "__DATA__ appearing elsewhere" If you data section has literal \f(CW\*(C`_\|_DATA_\|_\*(C'\fR in the data section, this module might be tricked by that. Although since its pattern match is greedy, \f(CW\*(C`_\|_DATA_\|_\*(C'\fR appearing \fIbefore\fR the actual data section (i.e. in the code) might be okay. .PP This is by design \-\- in theory you can \f(CW\*(C`tell\*(C'\fR the DATA handle before reading it, but then reloading the data section of the file (handy for developing inline templates with PSGI web applications) would fail because the pos would be changed. .PP If you don't like this design, again, use the superior Data::Section. .SS "utf8 pragma" .IX Subsection "utf8 pragma" If you enable utf8 pragma in the caller's package (or the package you're inspecting with the OO interface), the data retrieved via \&\f(CW\*(C`get_data_section\*(C'\fR is decoded, but otherwise undecoded. There's no reliable way for this module to programmatically know whether utf8 pragma is enabled or not: it's your responsibility to handle them correctly. .SH AUTHOR .IX Header "AUTHOR" Tatsuhiko Miyagawa .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright 2010\- Tatsuhiko Miyagawa .PP The code to read DATA section is based on Mojo::Command get_all_data: Copyright 2008\-2010 Sebastian Riedel .SH LICENSE .IX Header "LICENSE" This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" Data::Section Inline::Files