Some long-time REXX programmers switching to Perl find it difficult to give up REXX's template-based parsing abilities.
This module is my attempt to provide such parsing in Perl.
Consider it BETA level code.
The documentation assumes a familiarity with REXX parse statements.

The first EXPR is the source string to be parsed and must resolve to a scalar value.

The second EXPR is the template specification. The first time parse is called with a particular template, the template is compiled, then used to parse the source expression. Subsequent parse calls with the same template will use the previously compiled version of the template rather than compile the template again.

The template is specified as a single expression, usually using some single-quotish type of quoting, like q!...! for instance. The variable specifications, (or lvalue specifications) must not contain spaces. If you want data assigned to $qq{$one}, do not specify it as $qq{ $one } but as $qq{$one}. Although both are valid in Perl, only the latter is valid in a String::RexxParse template. Likewise, substr( $b , pos( $source ) , length( $match ) ) is NOT valid, but substr($b,pos($source),length($match)) is. Also, there must be white space following any lvalue specification (unless it's the last item in the template). q/$b $c/ is OK, but q/$b$c/ is not.

If a variable's value is to be used as a pattern, it is enclosed in parentheses.

Literal patterns are enclosed in either single or double quotes. Patterns can contain spaces within the quotes or parentheses.

A period (.) is used as a placeholder to skip part of the source string.

Numeric patterns (absolute or relative position) are supported. 3, =7, +5, -12, =($n), +($x), -($somenumber) are all numeric patterns (if you use variables inside parentheses preceeded by =, +, or -, make sure they contain numeric values). Remember that Perl starts counting position at zero, so absolute numeric patterns should be one less than in REXX to identify the same character position.

All Perl variables used must either be in the package that called parse, or they must be explicitly referenced with their package name (i.e., if parse is called from package Pack, $a implies $Pack::a -- if you want $a in package Sack, you must specify $Sack::a ). Lexical variables can not be used in the template. To assign values to lexical variables do somthing like this:

my ($b, $c, $d, $e) = parse $a, q! $x . $x '(' $x ')' $x !;

If you're concerned about the compiled templates taking up memory after you're done with them, you can add 'drop' to the import list when you 'use String::RexxParse'. Then pass the template to 'drop' when you're done with it. Or just call String::RexxParse::drop($template). Or use the object oriented flavor discussed below.

If you like, you can use String::RexxParse->new(EXPR) to create a String::RexxParse object. The EXPR passed to new is a template specification as described above. When you want to parse an EXPR, you just pass the string to the String::RexxParse object like so: $parse->parse(EXPR);

Please report any suspected bugs to Dan Campbell (String::RexxParse->email). Include the template and sample text that produces the incorrect results, along with a description of the problem. Questions and comments are also welcome.