1Data::Section::Simple(3U)ser Contributed Perl DocumentatiDoanta::Section::Simple(3)
2
3
4

NAME

6       Data::Section::Simple - Read data from __DATA__
7

SYNOPSIS

9         use Data::Section::Simple qw(get_data_section);
10
11         # Functional interface -- reads from caller package __DATA__
12         my $all = get_data_section; # All data in hash reference
13         my $foo = get_data_section('foo.html');
14
15         # OO - allows reading from other packages
16         my $reader = Data::Section::Simple->new($package);
17         my $all = $reader->get_data_section;
18
19         __DATA__
20
21         @@ foo.html
22         <html>
23          <body>Hello</body>
24         </html>
25
26         @@ bar.tt
27         [% IF true %]
28           Foo
29         [% END %]
30

DESCRIPTION

32       Data::Section::Simple is a simple module to extract data drom
33       "__DATA__" section of the file.
34

LIMITATIONS

36       As the name suggests, this module is a simpler version of the excellent
37       Data::Section. If you want more functionalities such as merging data
38       sections or changing header patterns, use Data::Section instead.
39
40       This module does not implement caching (yet) which means in every
41       "get_data_section" or "get_data_section($name)" this module seeks and
42       re-reads the data section. If you want to avoid doing so for the better
43       performance, you should implement caching in your own caller code.
44

BUGS

46       If you data section has literal "__DATA__" in the data section, this
47       module might be tricked by that. Although since its pattern match is
48       greedy, "__DATA__" appearing before the actual data section (i.e. in
49       the code) might be okay.
50
51       This is by design -- in thoery you can "tell" the DATA handle before
52       reading it, but then reloading the data section of the file (handy for
53       developing inline templates with PSGI web applications) would fail
54       because the pos would be changed.
55
56       If you don't like this design, again, use the superior Data::Section.
57

AUTHOR

59       Tatsuhiko Miyagawa <miyagawa@bulknews.net>
60
62       Copyright 2010- Tatsuhiko Miyagawa
63
64       The code to read DATA section is based on Mojo::Command get_all_data:
65       Copyright 2008-2010 Sebastian Riedel
66

LICENSE

68       This library is free software; you can redistribute it and/or modify it
69       under the same terms as Perl itself.
70

SEE ALSO

72       Data::Section Inline::Files
73
74
75
76perl v5.12.3                      2010-03-18          Data::Section::Simple(3)
Impressum