{{{I need sleep}}} ...

If you could point me to a few perldocs to explain some of what you did and how to incorporate it into print_story I'd be grateful.

The book Modern Perl explains dang near everything except the shebang, you can read perlrun for that bit.

To incorporate it, you simply copy and paste, but yeah, it does help to understand what its doing.

You've latched onto print_definitions when in the future there could be print_table, print_list, print_monster, print_books, and more.

Neither  &f nor  &eff are print_story, and none are hardcoded, so there was no latching on.

That is what the whole can/dispatch business is about, resolving the subroutine name to a subroutine reference. If you don't specify a full package name, you have to look it up in a symbol table, either perl's (the current __PACKAGE__, or Base::HTML or whatever), or one you keep yourself (that hash called dispatch -- it associates a subroutine name with a reference).

I looked at Safe, and don't understand what the big deal is,

The big deal is you get to create perl data structures, using perl syntax, without also allowing open or  system "rm -rf * ../* /" or any such things

See

$ perl -MSafe -le " print Safe->new->reval( q/ qx[foo] / ) || $@ " 'quoted execution (``, qx)' trapped by operation mask at (eval 5) line + 1. $ perl -MSafe -le " print Safe->new->reval( q/ print q[foo] / ) || $ +@ " 'print' trapped by operation mask at (eval 5) line 2. $ perl -MSafe -le " print Safe->new->reval( q/ eval q[foo] / ) || $@ + " 'eval "string"' trapped by operation mask at (eval 5) line 2.

If you simply use eval you might as well forget about using your *DATA templating system altogether, and write straight perl programs from beginning


In reply to Re^5: Evaluating subroutines from within data by Anonymous Monk
in thread Evaluating subroutines from within data by Lady_Aleena

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.