I'm trying to figure out exactly what opcode gives you the functionality to do quoted string interpretation, eg when you set $foo='FOO!'; and then print "$foo"; -- what changes "$foo" into 'FOO!'. So, I threw together this script... and it ain't workin. Anyone have any experience with the safe module and Text::Template?
#!/usr/bin/perl use Opcode; use Text::Template; use Safe; my @names = Opcode::opset_to_ops(Opcode::full_opset); foreach my $name (@names) { my (@feh); my ($cmptmt); undef $cmptmt; print "trying name $name..\t\t"; $cmptmt = new Safe; push @feh,$name; $cmptmt->permit_only(@feh); $Journal::true = 10; my $template_text = '{$true}'; my $template = new Text::Template (TYPE => 'STRING', SOURCE => $template_text, SAFE => $cmptmt); my $return_text = $template->fill_in(PACKAGE => Journal); if ($return_text eq "10") { print "return text is ok... "; $cmptmt1 = new Safe; $cmptmt1->permit_only(@feh); my $template_text1 = '{open(PASSWD,"/etc/passwd");read(PASSWD,$_,1 +,0);print}'; $template1 = new Text::Template (TYPE => 'STRING', SOURCE => $template_text1, SAFE => $cmptmt1); if ($return_text1 = $template1->fill_in(PACKAGE => Journal) == 1) { print "Um, ok?\n"; } else { print "Bad!!\n"; } } }

In reply to use Safe; by da w00t

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.