Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Checking number of values returned

by Anonymous Monk
on Feb 09, 2015 at 11:21 UTC ( [id://1116030]=note: print w/replies, xml ) Need Help??


in reply to Checking number of values returned

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 ';'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1116030]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-19 13:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found