Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

filter::eof(3pm) [debian man page]

Filter::EOF(3pm)					User Contributed Perl Documentation					  Filter::EOF(3pm)

NAME
Filter::EOF - Run a callback after a file has been compiled VERSION
0.04 SYNOPSIS
package MyPackage; use warnings; use strict; use Filter::EOF; sub import { my ($class, @args) = @_; my $caller = scalar caller; # set the COMPILE_TIME package var to a false value # when the file was compiled Filter::EOF->on_eof_call(sub { no strict 'refs'; ${ $caller . '::COMPILE_TIME' } = 0; }); # set the COMPILE_TIME package var to a true value when # we start compiling it. { no strict 'refs'; ${ $caller . '::COMPILE_TIME' } = 1; } } 1; ... package MyUsingPackage; use warnings; use strict; our $COMPILE_TIME; use MyPackage; # prints 'yes' BEGIN { print +( $COMPILE_TIME ? 'yes' : 'no' ), " " } # prints 'no' print +( $COMPILE_TIME ? 'yes' : 'no' ), " "; 1; DESCRIPTION
This module utilises Perl's source filters to provide you with a mechanism to run some code after a file using your module has been pro- cessed. METHODS
"import( @functions )" Currently, only a function equivalent of the "on_eof_call" method is provided for export. use Filter::EOF qw( on_eof_call ); sub import { my ($class) = @_; ... on_eof_call { ... }; } ... "on_eof_call( $code_ref )" Call this method in your own "import" method to register a code reference that should be called when the file "use"ing yours was compiled. The code reference will get a scalar reference as first argument to an empty string. if you change this string to something else, it will be appended at the end of the source. # call C<some_function()> after runtime. Filter->on_eof_call(sub { my $append = shift; $$append .= '; some_function(); 1;'; }); EXPORTS
on_eof_call You can optionally import the "on_eof_call" function into your namespace. EXAMPLES
You can find the example mentioned in "SYNOPSIS" in the distribution directory "examples/synopsis/". SEE ALSO
Filter::Call::Util, "Exporting without using Exporter's import method" in Exporter AUTHOR AND COPYRIGHT
Robert 'phaylon' Sedlacek - "<rs@474.at>". Many thanks to Matt S Trout for the idea and inspirations on this module. LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as perl itself. perl v5.8.8 2008-03-08 Filter::EOF(3pm)

Check Out this Related Man Page

HTML::Filter(3) 					User Contributed Perl Documentation					   HTML::Filter(3)

NAME
HTML::Filter - Filter HTML text through the parser NOTE
This module is deprecated. The "HTML::Parser" now provides the functionally of "HTML::Filter" much more efficiently with the the "default" handler. SYNOPSIS
require HTML::Filter; $p = HTML::Filter->new->parse_file("index.html"); DESCRIPTION
"HTML::Filter" is an HTML parser that by default prints the original text of each HTML element (a slow version of cat(1) basically). The callback methods may be overridden to modify the filtering for some HTML elements and you can override output() method which is called to print the HTML text. "HTML::Filter" is a subclass of "HTML::Parser". This means that the document should be given to the parser by calling the $p->parse() or $p->parse_file() methods. EXAMPLES
The first example is a filter that will remove all comments from an HTML file. This is achieved by simply overriding the comment method to do nothing. package CommentStripper; require HTML::Filter; @ISA=qw(HTML::Filter); sub comment { } # ignore comments The second example shows a filter that will remove any <TABLE>s found in the HTML file. We specialize the start() and end() methods to count table tags and then make output not happen when inside a table. package TableStripper; require HTML::Filter; @ISA=qw(HTML::Filter); sub start { my $self = shift; $self->{table_seen}++ if $_[0] eq "table"; $self->SUPER::start(@_); } sub end { my $self = shift; $self->SUPER::end(@_); $self->{table_seen}-- if $_[0] eq "table"; } sub output { my $self = shift; unless ($self->{table_seen}) { $self->SUPER::output(@_); } } If you want to collect the parsed text internally you might want to do something like this: package FilterIntoString; require HTML::Filter; @ISA=qw(HTML::Filter); sub output { push(@{$_[0]->{fhtml}}, $_[1]) } sub filtered_html { join("", @{$_[0]->{fhtml}}) } SEE ALSO
HTML::Parser COPYRIGHT
Copyright 1997-1999 Gisle Aas. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2008-04-04 HTML::Filter(3)
Man Page