what is the problem in this script and why it makes error

Posted on 2009-07-02
Last Modified: 2013-12-25
i have the attached script when I enter data and press the button it prints ok then display error message and I don't know why
I commented 2 lines because they made error
#use lib qw(/opt/lampp/bin/perl);
#use WebDB;
can you please tell me how to make the script work without comments
also this line I don't know what does it means
please help as soon as possible
best regards
hatem gamal
#! /opt/lampp/bin/perl -w


# - initial version of to-do application

use strict;

#use lib qw(/opt/lampp/bin/perl);

use CGI qw(:standard);

#use WebDB;

print header (),

	start_html (-title => "To-Do List", -bgcolor => "white"),

	h2 ("To-Do List");

# Dispatch to proper action based on user selection

my $choice = lc (param ("choice"));	# get choice, lowercased

if ($choice eq "")					# initial script invocation


	display_entry_form ();


elsif ($choice eq "submit")


	insert_item (param ("content"));

	display_entry_form ();




	print p ("Logic error, unknown choice: $choice");


print end_html ();


exit (0);

# ----------------------------------------------------------------------

# Insert new to-do item if the content is non-empty.


sub insert_item


my $content = shift;

my $dbh;

	$content =~ s/^\s+//;	# strip leading whitespace

	$content =~ s/\s+$//;	# strip trailing whitespace

	if ($content ne "")		# if content is non-empty, add to table


		$dbh = WebDB::connect ();

		$dbh->do (qq{

			INSERT INTO todo SET t = NOW(), status = 'open', content = ?

				}, undef, $content);

		$dbh->disconnect ();




# Display entry form


sub display_entry_form


	print start_form (-action => url ()),

		"To-do item:", br (),

		textarea (-name => "content",

					-value => "",

					-override => 1,

					-rows => 3,

					-columns => 80),

		br (),

		submit (-name => "choice", -value => "Submit"),

		end_form ();



Open in new window

Question by:hatem_from_mesr
  • 2

Assisted Solution

Fairlight2cx earned 350 total points
ID: 24763193
On the very first line, remove the space at position 3 after the #! sequence.
LVL 48

Assisted Solution

Tintin earned 150 total points
ID: 24771595
It would have been very helpful if you had posted the actual errors.

Line 6 will not generate any errors by itself, but it is incorrect as it should be a directory and not a filename.

Line 8 will get an error if the WebDB module is not installed in any of the standard Perl paths or in the path defined in line 6 (which is obviously the incorrect path)

Accepted Solution

Fairlight2cx earned 350 total points
ID: 24771683
By the way...

The #@ lines look to be someone's private convention for starting and stopping a block of code--notes to themselves, essentially.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now