NAME

Text::Vpp - Perl extension for a versatile text pre-processor

SYNOPSIS

 use Text::Vpp ;

 $fin = Text::Vpp-> new('input_file_name') ;

 $fin->setVar('one_variable_name' => 'value_one', 
			  'another_variable_name' => 'value_two') ;

 $res = $fin -> substitute ;

 print "Result is : \n\n",join("\n",@$res) ,"\n";

DESCRIPTION

This class enables to preprocess a file a bit like cpp.

First you create a Vpp object passing the name of the file to process, then you call setvar() to set the variables you need.

Finally you call substitute on the Vpp object.

NON-DESCRIPTION

Note that it's not designed to replace the well known cpp. Note also that if you think of using it to pre-process a perl script, you're likely to shoot yourself in the foot. Perl has a lot of built-in mechanism so that a pre-processor is not necessary.

INPUT FILE SYNTAX

Comments

All lines beginning with '#' are skipped. (May be changed with setCommentChar())

in-line eval

Lines beginning with '@EVAL' (@ being pompously named the 'action char') are evaluated as small perl script.

When setActionChar() is called with '#' as a parameter, Vpp doesn't skip lines beginning with '#'. In this case, there's no comment possible.

Multi-line input

Line ending with \ are concatenated with the following line.

Variables substitution

You can specify in your text varaibles beginning with $ (like in perl). These variables can be set either by the setVar() method or by the "eval" capability of Vpp (See below).

Setting variables

Line beginning by @ are "evaled" using variables defined by setVar(). You can use only scalar variables. This way, you can also define variables in your text which can be used later.

Conditional statements

Text::Vpp understands @IF, @ELSIF, @ENDIF,and so on. @INCLUDES and @IF can be nested.

@IF and @ELSIF are followed by a string which will be evaled using the variable you defined (either with setVar() or in the text).

Inclusion

Text::Vpp understands @INCLUDE

Constructor

new(file_name, optional_var_hash_ref, optional_action_char)

Create the file object. The second parameter can be a hash containing all variables needed for the substitute method.

Methods

substitute([output_file])

Perform the substitute, inclusion, and so on and write the result in "output_file". Returns 1 on completion, 0 in case of an error.

If output_file is not specified this function store the subtitution result in an internal variable. The result can be retrieved with getText()

getText()

Returns an array ref containing the result.

getError()

Returns an array ref containing the errors.

setVar( key1=> value1, key2 => value2 ,...) or setVar(hash_ref)

Declare variables for the substitute. Note that calling this function clobbers previously stored values.

setActionChar(char)

Enables the user to use another char as action char. (default @)

Example: setActionChar('#') will enable Vpp to understand #include, #ifdef ..

setCommentChar(char)

Enables the user to use another char as comment char. (default #)

AUTHOR

Dominique Dumont Dominique_Dumont@grenoble.hp.com

Copyright (c) 1996 Dominique Dumont. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

VERSION

Version 0.1

SEE ALSO

perl(1),Text::Template(3).