String::RexxParse

String::RexxParse is a Perl implementation of REXX parse command.
Download

String::RexxParse Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Dan Campbell
  • Publisher web site:
  • http://search.cpan.org/~blcksmth/String-RexxParse-1.08/RexxParse.pm

String::RexxParse Tags


String::RexxParse Description

String::RexxParse is a Perl implementation of REXX parse command. String::RexxParse is a Perl implementation of REXX parse command.SYNOPSISuse String::RexxParse qw(parse); parse $source, q! $var1 $var2 '(' $var3 ')' $var4 ($var5) $var6 !; or use String::PexxParse; $parse = String::RexxParse->new(q! $var1 $var2 '(' $var3 ')' $var4 ($var5) $var6 !); $parse->parse($source);SYNTAXparse EXPR, EXPRThe 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.Consult your favorite REXX manual for more details on templates.$parse = String::RexxParse->new(EXPR); $parse->parse(EXPR);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);What's New in This Release:· Fixed bug introduced in 1.07 and added j.t to test suite.


String::RexxParse Related Software