NAME

PerlIO::via::Include - PerlIO layer for including other files

SYNOPSIS

use PerlIO::via::Include;
PerlIO::via::Include->before( "^#include " );
PerlIO::via::Include->after( "\n" );
PerlIO::via::Include->regexp( qr/^#include(.*?)\n/ );

use PerlIO::via::Include before => "^#include ", after => "\n";

open( my $in,'<:via(Include)','file' )
 or die "Can't open file for reading: $!\n";

open( my $out,'>:via(Include)','file' )
 or die "Can't open file for writing: $!\n";

VERSION

This documentation describes version 0.04.

DESCRIPTION

This module implements a PerlIO layer that includes other files, as indicated by a special string, on input and on output. It is intended as a development tool only, but may have uses outside of development.

The regular expression indicating the filename of a file to be included, can be specified either with the before and after class methods, or as a regular expression with the regexp class method.

CLASS METHODS

The following class methods allow you to alter certain characteristics of the file inclusion process. Ordinarily, you would expect these to be specified as parameters during the process of opening a file. Unfortunately, it is not yet possible to pass parameters with the PerlIO::via module.

Therefore an approach with class methods was chosen. Class methods that can also be called as key-value pairs in the use statement.

Please note that the new value of the class methods that are specified, only apply to the file handles that are opened (or to which the layer is assigned using binmode()) after they have been changed.

before

use PerlIO::via::Include before => "^#include ";

PerlIO::via::Include->before( "^#include " );
my $before = PerlIO::via::Include->before;

The class method "before" returns the string that should be before the file specification in the regular expression that will be used to include other files. The optional input parameter specifies the string that should be before the file specification in the regular expression that will be used for any files that are opened in the future. The default is '^#include '.

See the after method for specifying the string after the filename specification. See the regexp method for specifying the regular expression as a regular expression.

after

use PerlIO::via::Include after => "\n";

PerlIO::via::Include->after( "\n" );
my $after = PerlIO::via::Include->after;

The class method "after" returns the string that should be after the file specification in the regular expression that will be used to include other files. The optional input parameter specifies the string that should be after the file specification in the regular expression that will be used for any files that are opened in the future. The default is "\n" (indicating the end of the line).

See the before method for specifying the string before the filename specification. See the regexp method for specifying the regular expression as a regular expression.

regexp

use PerlIO::via::Include regexp => qr/^#include(.*?)\n/;

PerlIO::via::Include->regexp( qr/^#include(.*?)\n/ );
my $regexp = PerlIO::via::Include->regexp;

The class method "regexp" returns the regular expression that will be used to include other files. The optional input parameter specifies the regular expression that will be used for any files that are opened in the future. The default is to use what is (implicitely) specified with before and after.

REQUIRED MODULES

(none)

EXAMPLES

Here will be some examples, some might even be useful.

SEE ALSO

PerlIO::via and any other PerlIO::via modules on CPAN.

COPYRIGHT

Copyright (c) 2002, 2003, 2004, 2012 Elizabeth Mattijsen. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.