Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Parser

Status
Not open for further replies.

spookie

Programmer
May 30, 2001
655
IN
Hi,
I want to check a perl program against a cetain checklist.
The checklist can be
1) if a perl script has 'use strict' in it.
2) There are no variables with the same name defined twice in the script.
3) To check if the loop condition is proper. i.e.incrementing operator and limit operator both are scalars.
etc.
What i can think at the moment is to parse the file line by line and use regex.
How do i go about this? Is there any module which can be used for the purpose?

Any suggestions are welcome.



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
what are you trying to do? Debug perl code? Not likely to be very accurate if you are thinking of using regexp's to try and evaluate perl code for correctness.

Get a perl IDE that can check your perl scripts in a variety of ways. There are some listed in the perl faqs page.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
The PPI module may be of some use to you. Its docs give a pretty good explanation of why parsing Perl code is practically impossible without using perl itself.
 
Thanks for the replies, guys!!

what are you trying to do? Debug perl code?
No, I don't exactly want to debug perl code. I want to check the code against specific checklist which is very specific to the project. E.g. For maintainablity reasons, a variable with same name can not be defined twice even in case of different scope, wheather a coder has used 'use strict' etc.


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top