Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Help with Perl

Reply
Thread Tools

Help with Perl

 
 
Brett Baisley
Guest
Posts: n/a
 
      03-02-2004
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


 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      03-02-2004
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

 
Reply With Quote
 
 
 
 
Joe Smith
Guest
Posts: n/a
 
      03-03-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 2.17 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? PerlFAQ Server Perl Misc 0 04-04-2011 10:00 PM
FAQ 1.4 What are Perl 4, Perl 5, or Perl 6? PerlFAQ Server Perl Misc 0 02-27-2011 11:00 PM
FAQ 2.17 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? PerlFAQ Server Perl Misc 0 02-03-2011 11:00 AM
FAQ 1.4 What are Perl 4, Perl 5, or Perl 6? PerlFAQ Server Perl Misc 0 01-23-2011 05:00 AM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments