develooper Front page | perl.perl5.porters | Postings from January 2012

[perl #107726] Filter::Simple with immediately following "no"

From:
Kevin Ryde
Date:
January 7, 2012 15:33
Subject:
[perl #107726] Filter::Simple with immediately following "no"
Message ID:
rt-3.6.HEAD-14510-1325979168-32.107726-75-0@perl.org
# New Ticket Created by  Kevin Ryde 
# Please include the string:  [perl #107726]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=107726 >


With recent debian perl 5.14.2, if a Filter::Simple module is turned off
with a "no" immediately after being turned on, like

    use MyFilter;
    no MyFilter;

then the remaining script after the "no" is ignored.  The attached
foo.el script and MyFilter.pm module show the problem.  Running

    perl foo.el

I expected it to print "this part is not filtered", but it doesn't.  If
you put a blank line after "use MyFilter" it does.

I struck this with Smart::Comments when I'd deleted everything between
use and no, but left those lines intending perhaps to add back some code
there shortly ...


Nosing around Filter::Simple it looks like when the terminator is found
on the very first call of the filter_add() handler, the handler returns
0, which the perl parser perhaps takes to mean EOF, and therefore stops
reading.

I expect it ought to return with "no MyFilter" or suitably mangled
terminator, to have that run as code.

Dunno if an empty "use/no" block ought to be shown to the FILTER{} etc
code of the subclass.  I suppose currently a "use MyFilter" immediately
followed by EOF has not called with an empty, so maybe no empties should
be shown to it, by default at least.





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About