• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Perl question

snoopdog

New Member
i just started learning Perl. And i tried the simplest script:

#!/usr/local/bin/perl
print "what's up!\n";

i uploaded it on netfirms, both folders(cgi-bin, www), cgi-bin gives me an internal error and www gives me this http://testperl2.netfirms.com/test.pl

What's wrong?
 
Last edited:
One of four problems then.
1) Is Perl actually at /usr/local/bin/perl? I've never used Netfirms, I don't know.
2) Did you upload it in ASCII mode?
3) Did you CHMOD it 755?
4) Try putting a blank line after the shebang, some servers are picky about that.

If all else fails, check your error log (assuming you have one).
 
Oh wait, silly me, I've gotten so used to writing prompt-based script I've forgotten all about CGI. The problem is you're not sending a header. You need to tell the browser what the document you're printing out is. For that you could either do:

print "Content-type: text/html\n\n";

...or:

print "Content-type: text/plain\n\n";
 
Originally posted by Dusty
One of four problems then.
1) Is Perl actually at /usr/local/bin/perl? I've never used Netfirms, I don't know.
2) Did you upload it in ASCII mode?
3) Did you CHMOD it 755?
4) Try putting a blank line after the shebang, some servers are picky about that.

If all else fails, check your error log (assuming you have one).
1) I don't know where their Perl is. Which host do you use?
2) My upload mode is set auto.
3) It was already CHMODed to 755, then i CHMODed it to 777 and now back to 755.
4) Nope the blank didnt help?
5) Where is my error log? I don't know.
Thanx for help though
 
Originally posted by Dusty
Oh wait, silly me, I've gotten so used to writing prompt-based script I've forgotten all about CGI. The problem is you're not sending a header. You need to tell the browser what the document you're print out is. For that you could either do:

print "Content-type: text/html\n\n";

...or:

print "Content-type: text/plain\n\n";
do i edit my print line or i insert this line below or above?
 
You've got to send a header for every page a script creates. After the header's sent, you can print out all you like on that page.
 
I don't find it hard. It may take a while to get into it, but you can say the same of any language.

I'm sure the more questions you ask and the more forums you frequent you'll be barraged with reason why PHP is so much easier and how Perl is a the most difficult language to blight the land, but ignore those professing that. Perl and PHP share more than a passing similarity and the one is really no more difficult than the other.

PHP is a fine language in it's own right, don't misunderstand me, but that in no ways detracts from Perl and its many uses. In my opinion Perl should be the language learned first, PHP promotes too many bad habits, but that's just me. I tend to prefer Perl for next to every Web programming situation.
 
Last edited:
I think Dustry is right, PHP lets you get lazy in your coding. There are so many functions that are useful, but you don't learn anything by using these functions.

Perl has many more uses than CGI though. PHP doesn't really. So, if you ever plan on doing more than CGI, Perl would be good to learn.

But, PHP is easier. It would be best to learn the basics of both, then choose what you like best. I don't think any one is faster or less resource intensive, if used right.
 
Code:
#!/usr/bin/perl
use strict;

print "Content-Type: text/html\n\n";
my $message = q(8454c4c4f4c202940216d6029557071607160224168616d616d616e20202e49636560247f602d65656470297f657e2020294660297f65702e65656460216e69702075627c6028656c607c20236f6d6560216e646021637b602d656);

### Damn VBull ###
$message =~ s/\n//gi;
$message =~ s/\s//gi;
##############

print pack("h*",$message);

__END__

... :classic2:
 
Originally posted by YUPAPA
Code:
#!/usr/bin/perl
use strict;

print "Content-Type: text/html\n\n";
my $message = q(8454c4c4f4c202940216d6029557071607160224168616d616d616e20202e49636560247f602d65656470297f657e2020294660297f65702e65656460216e69702075627c6028656c607c20236f6d6560216e646021637b602d656);

### Damn VBull ###
$message =~ s/\n//gi;
$message =~ s/\s//gi;
##############

print pack("h*",$message);

__END__

... :classic2:
What the hell!? You typed up all those letters and digits, just to say "HELLO, I am Yupapa Bahamama. Nice to meet you. If you need any perl help, come and ask me"? What is Perl that hard?!?! Then no way i'm gonna be memorizing those digits and letters, just to say who i am.
Cheers
 
I did it that way for fun!
you can do it this way!

Code:
#!/usr/bin/perl

print "Content-Type: text/html\n\n";
print "Hello\n";

__END__
 
Back
Top