Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Executive Summary: how can I get a source filter applied to required or evalled source code?

This came up while investigating some more features of load, when I suddenly realised that source filters have problems with AUTOLOADer modules, such as AutoLoader and SelfLoader (and of course The problem basically is that they're not applied to require'd or eval'ed source. For example, take this module which basically uppercases any strings between double quotes:

# package Foo; use Filter::Util::Call (); 1; sub import { Filter::Util::Call::filter_add( sub { my $status; if (($status = Filter::Util::Call::filter_read()) > 0) { s#("[^"]+")#\U$1\E#g; } $status; } ); } #import

This module is called in a script called "bar":

# bar use Foo; print "Hello World",$/; #require 'bar2'; # source is not filtered ;-( { local $/; open my $handle,'<','bar2' or die $!; $source = <$handle>; } #eval $source; # source is not filtered ;-( eval 'use Foo;'.$source; # even with importing again, source is not f +iltered ;-(

and the external file "bar2":

# bar2 print "Just Another Perl Hacker",$/;

and alas, the output is always:

Just Another Perl Hacker
whereas you would hope and/or expect:

These nodes seem related to this subject, but refer to other aspects of this problem I think.

I've been thinking a lot about this, but I guess I'm missing the right inspiration. I hope someone in the Monastery will have the right inspiration to fix this problem so I can add more features to


In reply to Source filters in eval/require by liz

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (5)
    As of 2018-06-24 19:19 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (126 votes). Check out past polls.