Next: Macro definitions Previous: Conditions Contents: Contents |
Variables can be used in the PerlPoint text and will be automatically replaced by their string values (if declared).
The next paragraph sets a variable. $var=var This variable is set to $var. |
All variables are made available to embedded and included Perl code as well as to conditions and can be accessed there as package variables of "main::". Because a variable is already replaced by the parser if possible, you have to use the fully qualified name or to guard the variables "$" prefix character to do so:
\EMBED{lang=perl}join(' ', $main::var, \$var)\END_EMBED |
Variable modifications by embedded or included Perl do not affect the variables visible to the parser. (This includes condition paragraphs.) This means that
$var=10 \EMBED{lang=perl}$main::var*=2;\END_EMBED |
causes $var
to be different on parser and code side - the parser will still use a value of 10, while embedded code works on with a value of 20.
Translator software can make additional use of variables, especially predeclare certain settings (such variables are usually capitalized). Please see your converters documentation for details.
Next: Macro definitions Previous: Conditions Contents: Contents |