LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-01-2020, 10:17 AM   #1
mjbradakis
Member
 
Registered: Apr 2012
Posts: 40

Rep: Reputation: Disabled
PERL syntax checker


Okay, I've searched around a bit and am having trouble finding what I want. I remember a while back there was a web site where you could type in a line or two or twenty of perl, and it would just go over it and make sure the syntax was correct. It would just check to see if brackets and parens were properly matched and stuff like that, no attempt to interpret or compile the code. You could paste in something like

Quote:
$uri =~ s/%%/\34/g;
$uri =~ s/%{?([a-z]+)}?/$param{$1}/g;
$uri =~ s/\34/%/g;
and it would flag any blatant errors.

Am I dreaming, or is something like this still around? I've not been an active sys admin for over 15 years, so I am certainly out of the loop. I'm trying to keep some old Namazu and MHarc based searchable email archives working as best I can.

http://autox.team.net/archive


Thanks for any help.

mjb.
 
Old 05-01-2020, 10:48 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Do you mean Execute Perl Online?

Last edited by shruggy; 05-01-2020 at 10:52 AM.
 
Old 05-01-2020, 10:50 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by mjbradakis View Post
Okay, I've searched around a bit and am having trouble finding what I want. I remember a while back there was a web site where you could type in a line or two or twenty of perl, and it would just go over it and make sure the syntax was correct. It would just check to see if brackets and parens were properly matched and stuff like that, no attempt to interpret or compile the code. You could paste in something like
Code:
$uri =~ s/%%/\34/g;
$uri =~ s/%{?([a-z]+)}?/$param{$1}/g;
$uri =~ s/\34/%/g;
and it would flag any blatant errors.

Am I dreaming, or is something like this still around? I've not been an active sys admin for over 15 years, so I am certainly out of the loop. I'm trying to keep some old Namazu and MHarc based searchable email archives working as best I can.

http://autox.team.net/archive
Don't know about such a site, but I personally use a context-sensitive editor/IDE. KDevelop is the one I prefer, but Anjuta is another. Both will 'color code' your source, and if there's a problem it'll highlight. In KDevelop, it can even auto-complete parens/brackets (if you enable it), so you always have a trailing one. That said, it will also highlight a different color if you DON'T have a matching bracket, and show you both.

This may work for you, though
https://services.w3.org/yacker/uploads/perl?lang=perl
http://perlcritic.com/
 
Old 05-01-2020, 11:23 AM   #4
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,794

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
I have always checked syntax with
perl -c
 
Old 05-01-2020, 12:16 PM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Quote:
Originally Posted by MadeInGermany View Post
I have always checked syntax with
perl -c
yes, there was a statement (actually about syntax highlighting of perl): only perl can correctly parse the perl code.
 
Old 05-01-2020, 12:42 PM   #6
mjbradakis
Member
 
Registered: Apr 2012
Posts: 40

Original Poster
Rep: Reputation: Disabled
Okay, an actual example of what I have happening. The Namazu script to generate indices returns this, in part, for some of the email lists:

Quote:
Useless use of greediness modifier '?' in regex; marked by <-- HERE in m/^\w+:{1,1}? <-- HERE / at /usr/local/share/namazu/filter/mp3.pl line 155
And I also get this:

Quote:
[root@autox bin]# perl -c /usr/local/share/namazu/filter/mp3.pl
/usr/local/share/namazu/filter/mp3.pl syntax OK
So perl claims it is correct, and perl claims it is incorrect. Which is why I am looking for something other than 'perl -c'


mjb.

ps:
Quote:
This is perl 5, version 28, subversion 2 (v5.28.2) built for x86_64-linux-thread-multi
 
Old 05-01-2020, 01:04 PM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by mjbradakis View Post
Okay, an actual example of what I have happening. The Namazu script to generate indices returns this, in part, for some of the email lists:
Code:
Useless use of greediness modifier '?' in regex; marked by <-- HERE in m/^\w+:{1,1}? <-- HERE / at /usr/local/share/namazu/filter/mp3.pl line 155
And I also get this:
Code:
[root@autox bin]# perl -c /usr/local/share/namazu/filter/mp3.pl
/usr/local/share/namazu/filter/mp3.pl syntax OK
So perl claims it is correct, and perl claims it is incorrect. Which is why I am looking for something other than 'perl -c'
ps:
Code:
This is perl 5, version 28, subversion 2 (v5.28.2) built for x86_64-linux-thread-multi
Use CODE tags when posting.

What you received was a warning, added in Perl 5.20. The code is technically CORRECT, and will compile and run...but it's telling you that you're doing something pointless.
https://github.com/Perl/perl5/issues/8899

Much the same as using STRICT will cause some code not to work, and removing the strict qualifier will let it work...it's just ignoring minor problems and/or best practices, in favor of things functioning.

Last edited by TB0ne; 05-01-2020 at 01:05 PM.
 
Old 05-01-2020, 01:19 PM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Quote:
Originally Posted by mjbradakis View Post
So perl claims it is correct, and perl claims it is incorrect.
No, perl claims it is useless. That means:
Code:
 Useless use of greediness modifier '?' in regex; marked by <-- HERE in m/^\w+:{1,1}? <-- HERE / at /usr/local/share/namazu/filter/mp3.pl line 155
the ? after the red part is useless, that has no any effect. Could be ignored/dropped. But accepted.
Actually {1,1} is pointless too, but need to see more to be sure about that.
 
1 members found this post helpful.
  


Reply

Tags
perl



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] "Error: syntax before '@' token and Error: syntax at 'OTHER' token" bullrider Programming 2 07-27-2009 08:00 AM
Starting httpd: httpd: Syntax error on line 209 of /etc/httpd/conf/httpd.conf: Syntax sethukpathi Linux - Networking 6 04-12-2008 11:26 AM
syntax checker naveensankineni Programming 1 02-22-2008 05:50 PM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 06:09 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration