This Class contains syntax check methods (class methods only).


($pos, $result) = SyntaxCkecks->validation_attribute_check_expression( $expr )
($pos, $result) = SyntaxCkecks->validation_attribute_check_expression( $expr, $cgi )
This method checks the syntax of a Perl expression which tests validation attributes.

The first argument is a Perl expression, which will be syntax checked.

The second argument is optional, it may be a handle to a CGIsession object, if the method is called from a CGI script. It is only used to determinate, if error messages should be formatted for HTML output. A CGI script could obmit the second argument - the only difference will be, that error messages are formatted for plain text output (without HTML tags).

The method returns two values: $pos and $result.

If $pos is defined, there was an error and $pos indicates at which character position the scanner found a problem; while $result will be a string which will describe the error. If $pos is 0 (zero), there was an error, but the postion is irrelevant.

If $pos is undef, the check was successful and $result contains the expression untainted and reformatted: some spaces may have been added or removed.

The expression is checked so that it can be used in a eval statement and will have no side effects. Only references to the hash %attr and to strings or numbers are allowed, they may be compared and tested with pattern matches, but no other operations can be performed with them. Functions can not be called and references to variables or blocks are forbidden in patterns and doublequoted strings.


Examples of validation_attribute_check_expression calls can be found in method update of class Roles.pm and in the CGI script cgi-bin/admin/roles/edit.cgi.


Copyright 2004-2013 Thedi gerber@id.ethz.ch