in reply to PERL-CGI on shared unix server
Your question is somewhat vague, as to exact needs. But then again, Perl is new to you. So you get a pass this time. ;-)
If I had to guess; I'd say you're looking to discover how to run/execute Perl scripts on your hosted web/internet account, and how to print (produce) Perl/CGI driven web pages. That's a pretty large topic to cover in a single reply on Perl Monks. But using your provided example in the OP; I might suggest using the feature/say . It's a bit like Heredoc ( Here Document ). Here's my version using Feature say:
As you can see, it's quite a bit simpler. While I'd have generally dumped all the commonly used stuff into a sub, of even made, or used an existing module that already provided that. All of that strays from your question. So I'll refrain from digression. :-)#!/usr/local/bin/perl -w use strict; use feature qw(say); print "content-type:text/html; charset=utf-8\n\n"; say qq~<!DOCTYPE html> <html lang="en"><head> <title>Hello, world!</title> </head><body> <h1>Hello, world!</h1> </body></html>~;
Secondly; you'll need to know where your hosing provider puts Perl for it's users. So you can use the right "shebang, or just "bang". That refers to the first line:#!/usr/local/bin/perl . Generally speaking, and as you noted you're on a *NIX platform. Your choices are either in /usr/bin/perl , or /usr/local/bin/perl. You can best determine that by way of which , or whereis . A couple of *NIX commands that tell you -- if you haven't already guessed; where stuff is. :-). So here's an example session:
or# which perl /usr/local/bin/perl
As you can see, the output is different; the command whereis being quite a bit more informative. :-)# whereis perl perl: /usr/local/bin/perl /usr/local/lib/perl5/5.26/perl/man/man1/perl +.1.gz /usr/src/contrib/file/magic/Magdir/perl
Lastly. You'll need/want to know where your hosting provider allows you to execute Perl scripts. This information should have been provided in the TOS (Terms of Service) you were required to agree to, when you signed up. Or it might also be in a FAQ (Frequently Asked Questions) they have on their site.
Well, I think that probably covers it.
HTH
--Chris
Evil is good, for without it, Good would have no value
¡λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH
|
---|