Thank you! This link was very helpful and it provided a link to -- I think -- a solid description explaining this behavior <https://perldoc.perl.org/SelfLoader.html#The-__DATA__-token>.
but for other modules data after __END__ <https://perldoc.perl.org/functions/__END__.html> is not automatically retrievable @mojocore: What do you think about adding this tip to one or both of these sections? Mojo::Loader#data_section Extract embedded file from the C<DATA> section of a class, all files will be cached once they have been accessed for the first time. *C<DATA> sections inclasses other than C<main> should be placed before C<END> sections.* Mojolicious::Guides##Renderer All templates should be in the C<templates> directories of the application, which can be customized with L<Mojolicious::Renderer/"paths">, or one of the the C<DATA> sections from L<Mojolicious::Renderer/"classes">. *C<DATA> sectionsin classes other than C<main> should be placed before C<END> sections.* Here's a Perl test demonstrating this behavior: $ cat end_data.t package EndData; use Test::More; { local $.; my $class = __PACKAGE__; my $handle = do { no strict 'refs'; \*{"${class}::DATA"} }; my $fileno = ok !fileno($handle); SKIP: { skip "DATA filehandle could not be opened", 2 if $fileno; ok seek($handle, 0, 0); like join('', <$handle>), qr(__END__.*?__DATA__); } } done_testing; __END__ abc __DATA__ def $ cat data_end.t package DataEnd; use Test::More; { local $.; my $class = __PACKAGE__; my $handle = do { no strict 'refs'; \*{"${class}::DATA"} }; my $fileno = ok fileno($handle); SKIP: { skip "DATA filehandle could not be opened", 2 unless $fileno; ok seek($handle, 0, 0); like join('', <$handle>), qr(__END__.*?__DATA__); } } done_testing; __DATA__ def __END__ abc $ prove -v end_data.t data_end.t end_data.t .. ok 1 ok 2 # skip DATA filehandle could not be opened ok 3 # skip DATA filehandle could not be opened 1..3 ok data_end.t .. ok 1 ok 2 ok 3 1..3 ok All tests successful. Files=2, Tests=6, 0 wallclock secs ( 0.01 usr 0.01 sys + 0.05 cusr 0.00 csys = 0.07 CPU) Result: PASS On Sat, Feb 22, 2020 at 9:41 AM Mike Lieman <mikelie...@gmail.com> wrote: > >The two control characters ^D and ^Z, and the tokens __END__ and __DATA__ > may be used to indicate the logical end of the script before the actual end > of file. * Any following text is ignored.* > > https://perldoc.perl.org/perldata.html#Special-Literals > > On Sat, Feb 22, 2020 at 10:12 AM Stefan Adams <s1037...@gmail.com> wrote: > >> I just spent more time than I should admit about figuring this out. >> >> *Templates in the DATA section must come before the END section.* >> >> Is this common to all of Perl that DATA must come before END? Can anyone >> point me to a document resource for this, so that I can read it and beat it >> into my head? This is not the first time I've gotten tripped up on this. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Mojolicious" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to mojolicious+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/mojolicious/CACyQ%2BFQZykiSrmiFxoEdRYB-KdOw%3DeDPTQ86zC%3DNu428EuOJEA%40mail.gmail.com >> <https://groups.google.com/d/msgid/mojolicious/CACyQ%2BFQZykiSrmiFxoEdRYB-KdOw%3DeDPTQ86zC%3DNu428EuOJEA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mojolicious+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/mojolicious/CAG2_C8CWUeAvZ6fguaaADBqzDV4PZBhvrh%2ByUBsx8H5g%3D6_xoQ%40mail.gmail.com > <https://groups.google.com/d/msgid/mojolicious/CAG2_C8CWUeAvZ6fguaaADBqzDV4PZBhvrh%2ByUBsx8H5g%3D6_xoQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/CACyQ%2BFQsU8KP%3D0Dp6DergHyjC5KQWBMnz1rLkUgxn91O0e-YUw%40mail.gmail.com.