Web Design and Development Forums

A perl n00b needs your help!

This is a discussion on "A perl n00b needs your help!" within the Perl, Python, Ruby and Others section. This forum, and the thread "A perl n00b needs your help! are both part of the Program Your Website category.

Old Jul 20th, 2007, 11:35   #1 (permalink)
New Member
 
Join Date: Jul 2007
Location: Ireland
Age: 17
Posts: 2
Unhappy A perl n00b needs your help!

<--The sheep's perdy cool ain't it? I like these forums..

Hi, I'm a n00b to this website so I'm sorry if I'm posting in the wrong place and please don't murder me! My problem is I have a form and am trying to use perl to submit/post/send it. But every time I did this I got a 405 error. Since then I've been on some other sites and forums and found a line to insert into my .htaccess file (It's Options ExecCGI). That seems to have solved the preliminary problem but now I have a new one in that fire fox displays a message saying: Firefox has detected that the server is redirecting the request for this address in a way that will never complete. Not only am I a n00b to these forums but I'm also one to perl, I have beside me an O'Reilly book on CGI programming (the one with the rat on it) and so far I'm still on the first post example in it. It's only a little greeting! I feel so stupid having to ask you lot with something so small! I don't see how I'm going to get the advice/learn otherwise, I'm the only one in the office with any knowledge of web design (Trying to sort out the companies website).

If it makes much difference the site's on a linux server and I'm using a mac (without dreamweaver, this would be so much easier if I had dreamweaver!) so I'm hard coding with pagespinner (the trial version).


Thanks guys (and gal's o' course) your advice is really needed!
IchigoFork is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jul 20th, 2007, 12:22   #2 (permalink)
 
Join Date: May 2006
Location: North West, UK
Age: 21
Posts: 1,389
Re: A perl n00b needs your help!

You're very brave. Perl isn't an easy language. I had a little go a little while back and ended up frustrated big time. Same happened for me with ruby I got the pragmatic programmers guide and got lost withing a few pages.

A form would be very simple (and I mean disgustingly so) with php. A very simple one could be done with a few lines of code.

Here is a free mac text editor specifically designed for coding etc.

TextWrangler

Pete.
pa007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jul 20th, 2007, 12:28   #3 (permalink)
Up'n'Coming Member
 
Join Date: Sep 2006
Location: UK
Posts: 65
Re: A perl n00b needs your help!

If you posted the code you are trying to use it would greatly help.
balaclave is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jul 20th, 2007, 12:29   #4 (permalink)
 
Join Date: May 2006
Location: North West, UK
Age: 21
Posts: 1,389
Re: A perl n00b needs your help!

Don't tell me you're a perl whizz as well? Is there anything you can't do?

Pete.
pa007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jul 20th, 2007, 13:05   #5 (permalink)
New Member
 
Join Date: Jul 2007
Location: Ireland
Age: 17
Posts: 2
Red face Re: A perl n00b needs your help!

Thanks for the mac text editor link, I'll go have a look at it as soon as I've finished posting.

Really? That would be fantastic, we need a quick fix down here asap to get the form online, can't have customer's going to dead links can we? I wanted to learn php more than I did perl but, alas, there were no books to be found in my house on php. I was going to try a code which would make sure all the fields had something in them, I saw something like I was looking for on a site yesterday but going to the url of the perl file like I usually do with html and css pages wasn't working.. But that'll at least take a solid weekend to figure and that's <i>after</i> I know what I'm doing.
I definetly want to continue learning perl though. No question to that, I hate leaving things unfinished or unresolved (they give me nightmares).

And of course you'll need the code to figure out what's wrong! Silly me, sorry. This is the quick greeting code though, ('Quick' my left big toe, it's taken me the morning to type it out and since then I've been trying to fix it.) but if I knew what was wrong with it, I could learn from it.

Without further ado, here's the code:

#!/usr/local/bin/perl
$webmaster = "info\@selprint\.com";
&parse_form_data (*simple_form);
print "Content-type: text/plain", "n/n";
$user = $simple_form{'user'};

if ($user) {
print "Nice to meet you ", $simple_form{'user'}, ".", "\n";
print "Please don't eat the bread!", "\n";
} else {
print "You didn't enter a name, perhaps you haven't any fingers?", "\n";
print "Poor you, you sould try and see if you can get some bionic ones or something..", "\n";
}

exit(0);

sub parse_form_data
{
local (*FORM_DATA) = @_;
local ( $request_method, $query_string, @key_value_pairs,
$key_value, $key, $value);

$request_method = $env{'request_method'};

if ($request_method eq "get") {
$query_string = $env{'query_string'};
} elseif ($request_method eq "post") {
read (stdin, $query_string, $env{'content_length'});
} else {
&return_error (500, "Server Error",
"Server uses unsupported method");
}

@key_value_pairs = split (/&/, $query_string);

foreach $key_value (@key_value_pairs) {
($key, $value) = split (/=/, $key_value);
$value =~ TR/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;


if defined($FORM_DATA{$key})) {
$FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value);
} else {
$FORM_DATA{$key} = $value;
}
}
}

sub rturn_error
{
local ($status, $keyword, $message) = @_;

print "Content-type:text/html', "\n";
print "Status: ", $status, " ", $keyword, "\n\n";

print<<End_of_Error;

<ttitle> CGI Program - Unexpected Error</title>
<h1>$keyword</h1>
<hr>$message</hr>
Please contact $webmaster for more information.

End_of_Error

exit(1);
}
IchigoFork is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jul 20th, 2007, 18:41   #6 (permalink)
Up'n'Coming Member
 
Join Date: Sep 2006
Location: UK
Posts: 65
Re: A perl n00b needs your help!

@Pete: No I'm not very good with perl but it is similar to many programming languages. It's like learning an instrument. Once you learn one, you know how to read the musical notation, so learning another is considerably easier.
Same goes with most programming languages because they are all similar.

So in that sense, I can kind of tell what is happening and see if anything seems illogical.

Then I can ask Master Google for his advice.

@IchigoFork:
Quote:
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This suggest something is wrong with the HTTP headers.

Try this:
change the fourth line from:
Code: Select all
print "Content-type: text/plain", "n/n";
to:
Code: Select all
print "Content-type: text/plain", "\n\n";
balaclave is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
beginner, perl

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
N00b-ish questions for building a site Pong Beginner Resources 1 Jan 6th, 2008 10:38
Hi, Complete n00b! jotto Introduce Yourself 8 Aug 29th, 2007 19:20
N00b Trying To Learn Some Tricks Splendor New to Web Design 3 Mar 14th, 2007 11:11
n00b learning PHP Micky-D PHP Forum 4 Oct 6th, 2006 00:24
Self taught Simi-n00b Micky-D Introduce Yourself 2 Jun 17th, 2005 09:16



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 23:07.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59