Home > other >  Is there a way to check correct syntax in nested files in VCS, let them know who is parent? Like in
Is there a way to check correct syntax in nested files in VCS, let them know who is parent? Like in

Time:06-03

I started to work with Visual Studio Code, and it's super cool with syntax correction warnings. I used to work 20 years under Linux shell in Vim.

But now I can see too much error related to global variables, like Global symbol "%contents" requires explicit package name. It's very disturbing.

It's maybe more Visual Studio Code related, like some extension plugin could do it.

Or it can be handle trough some Perl function, so it can solve also classic "perl -c" shell check.

My situation:

I have Perl FCGI script fcgi.cgi, which require functions.pl on start, then loads all pages from files to memory using global hash variable, which are separated to "html" and "pl" file for each page (1762 files, size 16MB), and runs in like 20 threads.

On any Apache call, it just call a thread, and runs "eval" on selected "pl" page from memory, fill selected "html", and superfast generate the page, like in 0,1 sec. File "functions.pl" has only "sub" functions and they are available to all "pl" scripts.

Files:
|/fcgi-bin/fcgi.cgi
|/pages/page1.pl
|/pages/page1.html
|/pages/page2.pl
|/pages/page2.html
|/functions/functions.pl

So is there any way to add some info to header to "/pages/page1.pl" and "/functions/functions.pl", that "/fcgi-bin/fcgi.cgi" is the parent script? So it will check syntax like its in one file.

And for "/pages/page1.pl" that "/fcgi-bin/fcgi.cgi" is the parent, and "/functions/functions.pl" is library.

I can image, that just for the syntax check i can copy content of those files, in beginning of checked files, and the syntax check will work.

Or I can simply add it with some extension, like for example:

#!/usr/bin/perl

#this is /pages/page1.pl

###extenstion call add for check: "/fcgi-bin/fcgi.cgi"###
###extenstion call add for check: "/functions/functions.pl"###

#normal code, using variables from /fcgi-bin/fcgi.cgi and functions from /functions/functions.pl 

So I hope it's understandable. It's not related to specific code, it's a common issue, that can be in other programming languages too. So there is no example code. And I hope for some Visual Studio Specific code solution. I thing, that Perl solutions could be done only by reprogramming my 20 years work to some "use Lib package" definition, and thats not possible.

CodePudding user response:

It sounds like you don't like that your new environment shows you the warnings that you were ignoring (or not seeing) before. If you don't want to fix those, you probably don't want a tool that shows them to you.

Stop using global variables, which is a good design decision. And, if you have to use them, declare them with use vars or our, or use the fully-qualified name.

But, your problem seems to be that you'd have to do this in an intractable number of places. (But, you have Perl and source control!)

I might suggest that you figure out how to turn off warnings in VSCode's call out to perl, like with the -X switch, but that's not really that helpful if you want syntax checking. A local $^W=0 might help in places.

  • Related