500 Internal Server Error when run perl file and no access to command line
Perhaps your file is being run, and the problem is that it doesn't output a valid HTTP response? I'd fix that first, though I'm not sure if the file is being run or not.
This is close to the minimal response:
#!/usr/bin/env perl
print "HTTP/1.1 200 OK\r\n";
print "Content-Type: text/plain\r\n";
print "\r\n";
print "test\r\n";
Use of env in the first line is optional, but makes your code more general and is a good habit.
You can usually count on your web server to do a few bits for you, so a slightly simpler version would be:
#!/usr/bin/env perl
print "Content-Type: text/plain\n\n";
print "test\n";
It is good to start using suitable libraries as soon as you are ready for them. Have a look at https://perlmaven.com/hello-world-with-plain-cgi for some sample code. If you've done a bit in other languages and are familiar with object oriented concepts, then you should probably start with CGI::Simple in perl.
If your perl script isn't being executed at all, then you need to know a bit about how the web server is configured. The web server (e.g. it might be apache or nginx) needs to see the .pl
suffix and know to run the file with perl. It might or might not be configured that way. It might be that it wants you to use a .cgi
suffix, or you might need to put the file in a /cgi-bin/
directory at the top of your site. If your not sure, then ask your hosting provider.