There's also PPI, which does a relatively good job of parsing Perl.
With PPI it should certainly be possible to identify and check that subset of your returns and function calls which take some regular, identifiable form. I'm not (yet) aware of existing code that already does this, but I could be missing something. Maybe one of the many Perl::Critic policies could provide a starting point...
use PPI; my $doc = PPI::Document->new( \<<'ENDPERL' ); sub foo { return 1, 2, 3 } my ($x, $y, $z) = foo(); ENDPERL use PPI::Dumper; PPI::Dumper->new( $doc, whitespace=>0 )->print; __END__ PPI::Document PPI::Statement::Sub PPI::Token::Word 'sub' PPI::Token::Word 'foo' PPI::Structure::Block { ... } PPI::Statement::Break PPI::Token::Word 'return' PPI::Token::Number '1' PPI::Token::Operator ',' PPI::Token::Number '2' PPI::Token::Operator ',' PPI::Token::Number '3' PPI::Statement::Variable PPI::Token::Word 'my' PPI::Structure::List ( ... ) PPI::Statement::Expression PPI::Token::Symbol '$x' PPI::Token::Operator ',' PPI::Token::Symbol '$y' PPI::Token::Operator ',' PPI::Token::Symbol '$z' PPI::Token::Operator '=' PPI::Token::Word 'foo' PPI::Structure::List ( ... ) PPI::Token::Structure ';'
In reply to Re: Checking number of values returned
by Anonymous Monk
in thread Checking number of values returned
by jfrm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |