473,387 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with Perl

Hello

I'm new to Perl and taking it as part of my class. I am making a Perl
program that does some calculations and depending on the result it gets, it
either failed or successful. If it fails, it calls the fail sub called
failPage().

I am not sure how to get it to work, specifially, how to call a function.

This is what I am testing with:

#!/usr/bin/perl -w
use CGI ":standard";
failPage();

then it should call the failPage sub, which simply prints "Fail" to the
page. However, it doesn't work. It says a server error, so I'm doing
something wrong.

Any suggestions?

Thanks
Jul 19 '05 #1
2 1483
Brett Baisley wrote:
I'm new to Perl and taking it as part of my class. I am making a
Perl program that does some calculations and depending on the
result it gets, it either failed or successful. If it fails, it
calls the fail sub called failPage().

I am not sure how to get it to work, specifially, how to call a
function.

This is what I am testing with:

#!/usr/bin/perl -w
use CGI ":standard";
failPage();

then it should call the failPage sub, which simply prints "Fail" to
the page. However, it doesn't work. It says a server error, so I'm
doing something wrong.


You are obviously trying to execute the program as a CGI script (i.e.
from a browser), which is something that you are probably not supposed
to do in a Perl class for beginners.

Run the program from the command prompt.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #2
Brett Baisley wrote:
#!/usr/bin/perl -w
use CGI ":standard";
failPage();


Immediately after "use CGI" add this line:
use CGI::Carp 'fatalsToBrowser';

Next time, post the significant parts of the program.

The three lines you posted are obviously missing the part with
sub failPage {
print header(-type => 'text/plain'); print "Failed\n";
}

Better yet, design your program so that is can be run from the
command line, either a Unix/Linux shell or from the "C:\>" prompt.
-Joe
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then...
0
by: pptran | last post by:
Hi, I am pretty new to building and installing Perl. Can someone help explain the severity of the following Perl 5.8.4 build error message? ==================================================...
3
by: kevin | last post by:
Is that even possible? I am creating a web service in .NET to expose some already created .NET programs to other groups. One group is writing the client in PERL, and thus wishes the wsdl schema...
0
by: gedsta | last post by:
Hi all I am a total noob and its my 2nd post, first of all thank you for letting me use these forums as a source of information, and hopefully once i get my head round perl i maybe able to help...
2
by: MK | last post by:
Hello, I am new to XML and PERL and I have a few questions the answers to which I need to complete a project. All your time and effort would be highly appreciated. I have to make a small HTML page...
3
by: rahul sinha | last post by:
Hi, I am using an Apache2Triad web server to execute my PHP scripts on my local machine. What I want to do now is to execute a perl project on it.How can I do that? How to check the web server...
2
by: sangith | last post by:
Hi, I am trying to understand a concept in Regex in Perl. How to write regex in Perl such that metacharacter * is not greedy. Here is my code:- #!usr/bin/perl use strict; my $sentence =...
2
by: geniuskanwal | last post by:
Before I begin to explain my problem, I just want to say that I can do the following two things: 1. Using Perl, connect to a MS Access Databse Table and perform the required operations.(Database...
4
by: negzero7 | last post by:
Hi everyone, I am trying to teach myself Perl with the aid of some books I have boughten. I'm doing some exercises with regular expressions but am having some trouble, specifically with this...
11
by: bthalapathi | last post by:
I have written a script to connect the mysql db #!/usr/bin/perl -w use DBI; #definition of variables $db="MYTEST"; $host="localhost"; $user="root"; $password="rootpass";
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.