perlfilter

perlfilter package contains Perl source filters.
Download

perlfilter Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Paul Marquess
  • Publisher web site:
  • http://search.cpan.org/~pmqs/IO-Compress-Bzip2-2.012/lib/IO/Compress/Bzip2.pm

perlfilter Tags


perlfilter Description

perlfilter package contains Perl source filters. perlfilter package contains Perl source filters.This article is about a little-known feature of Perl called source filters. Source filters alter the program text of a module before Perl sees it, much as a C preprocessor alters the source text of a C program before the compiler sees it. This article tells you more about what source filters are, how they work, and how to write your own.The original purpose of source filters was to let you encrypt your program source to prevent casual piracy. This isn't all they can do, as you'll soon learn. But first, the basics.CONCEPTSBefore the Perl interpreter can execute a Perl script, it must first read it from a file into memory for parsing and compilation. If that script itself includes other scripts with a use or require statement, then each of those scripts will have to be read from their respective files as well.Now think of each logical connection between the Perl parser and an individual file as a source stream. A source stream is created when the Perl parser opens a file, it continues to exist as the source code is read into memory, and it is destroyed when Perl is finished parsing the file. If the parser encounters a require or use statement in a source stream, a new and distinct stream is created just for that file.The diagram below represents a single source stream, with the flow of source from a Perl script file on the left into the Perl parser on the right. This is how Perl normally operates. file -------> parserThere are two important points to remember:Although there can be any number of source streams in existence at any given time, only one will be active.Every source stream is associated with only one file.A source filter is a special kind of Perl module that intercepts and modifies a source stream before it reaches the parser. A source filter changes our diagram like this: file ----> filter ----> parserIf that doesn't make much sense, consider the analogy of a command pipeline. Say you have a shell script stored in the compressed file trial.gz. The simple pipeline command below runs the script without needing to create a temporary file to hold the uncompressed file. gunzip -c trial.gz | shIn this case, the data flow from the pipeline can be represented as follows: trial.gz ----> gunzip ----> shWith source filters, you can store the text of your script compressed and use a source filter to uncompress it for Perl's parser: compressed gunzip Perl program ---> source filter ---> parser Requirements: · Perl


perlfilter Related Software