LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-10-2005, 05:42 PM   #1
Cool_Hand_Luke
Member
 
Registered: Feb 2005
Posts: 40

Rep: Reputation: 15
New to Perl


I am running a fresh install of Mandrake 9.1 with Perl 5.8

All of this was set up automatically. I am just learning and wanted to play around making my own form handler from scratch using the book "Perl and CGI for the World wide Web" From my understanding CGI.PM was supposed to be installed automatically with version 5.04 or higher.

My scripts work when I write simple things without any calls from form variables. I get an error when I add the following line at the top under the shebang line.

use CGI ':standard';

I also get an error when I try and load CGI.pm



Do I need the above modules to accept code with the param function from forms? See the example below:


my $formdata;
$formdata=param('nameinform');
print "Is this the data $formdata";

The HTML file that would run that script doesn;t work. However I can link to the script and get proper output as long as I don't try to use any name values from the form.

Any ideas?

Cheers,

Luke

Last edited by Cool_Hand_Luke; 03-10-2005 at 07:24 PM.
 
Old 03-10-2005, 07:31 PM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Try ' perldoc CGI ' in command line for more infos
 
Old 03-10-2005, 08:02 PM   #3
Cool_Hand_Luke
Member
 
Registered: Feb 2005
Posts: 40

Original Poster
Rep: Reputation: 15
That does not work...
 
Old 03-10-2005, 11:50 PM   #4
TheLinuxDuck
Member
 
Registered: Sep 2002
Location: Tulsa, OK
Distribution: Slack, baby!
Posts: 349

Rep: Reputation: 33
Cool_Hand_Luke:

Firstly, try including CGI w/o the ':standard', as:
Code:
use CGI;
Second, what error does it return? Does it say "No CGI.pm in @INC (list of dirs)"? If so, then it's a safe bet to say that CGI.pm is NOT installed on your system. If it is not installed, then installing it can be done by several methods (using the CPAN module, etc).

Thirdly, in order to access the form data, yes CGI.pm has to be installed and included in the script.

And lastly, as a perl beginner, I would strongly suggest that you always start every perl script as:
Code:
#!/usr/bin/perl
use strict;
use warnings;
use strict; will be your worst enemy and your best friend, because it will force your coding style to a certain standard. It will get you writing better code earlier. This google search will provide you with a plethora of reading material on it's use. use warnings; is also good because it's provides you with somewhat more informative error messages when things do go wrong in your scripts.

And, if you're getting some error in a perl script that you just can't seem to understand, add
Code:
use diagnostics;
to the script's header. This will provide you with a detailed description of the error, and possible generic causes.. however, using it will slow your script down tremendously, and it's not a good idea to leave this included all the time.

Let me finally add that I'm glad to see someone interested in learning perl, and I also hope that you find as much help as needed to keep your interest going and your success rate high! (=
 
Old 03-11-2005, 06:31 AM   #5
Cool_Hand_Luke
Member
 
Registered: Feb 2005
Posts: 40

Original Poster
Rep: Reputation: 15
Great! Thanks for the help I really appreciate it!

I will try this tonight again.

This is sort of a hobby for me. I have taken limited courses in web developement and CISC 101 which was java programming. I find it fun. :-)

Cheers,

Cool Hand...
 
Old 03-11-2005, 04:30 PM   #6
Cool_Hand_Luke
Member
 
Registered: Feb 2005
Posts: 40

Original Poster
Rep: Reputation: 15
Talking

OMG It is working Yahoo!!!!!!

I am so excited!! For all of you GURUS!! Let this remind you of how it must have felt when you sucessfully wrote your first program

YYYYYYYYYYAAAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!!!!!!! !!!


LMAO

Cheers,

Cool Hand...
 
Old 03-11-2005, 04:34 PM   #7
TheLinuxDuck
Member
 
Registered: Sep 2002
Location: Tulsa, OK
Distribution: Slack, baby!
Posts: 349

Rep: Reputation: 33
(= Good to hear! Just post if you've any other questions, and hopefully someone will be able to assist.

As for the feeling of the first working code, I typically feel pretty ecstatic when something actually
works like I meant. (= Those are the good days. (=
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 05:37 PM
For begginer,where can I start NoThing Linux - General 1 08-03-2004 12:01 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
Linux for Begginer destroyer30 Linux - Newbie 6 04-27-2003 08:49 PM
chrooting apache v2 (php, ssl, perl support) ; perl configuration markus1982 Linux - Security 3 01-26-2003 06:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration