Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Contents

1. What Is Perl?
2. Course Requisites and Goals
3. Perl References & Resources
4. State of Perl
5. Taste of Perl
6. Storing & Running Perl Programs
7. The Elements
8. Literals & Operators
    9. Loops and I/O
10. Grade Book Example
11. Pipe I/O and System Calls
12. Matching
13. Parsing
14. Simple CGI
15. Testing Perl Programs
16. Common Goofs

15. Testing Perl Programs

Use the compiler -w switch to warn about identifiers that are referenced only once, uninitialized scalars, redefined subroutines, undefined file handles, probable confusion of "==" and "eq", and other things. This can be coded in the magic cookie first line:

    #!/usr/local/bin/perl -w

As you write your program, put in print statements to display variables as you proceed. Comment "#" them out when you feel you don't need to see their output.

CGI scripts require some special attention in testing.

MU's "showme" and "SGI" Web servers (www.missouri.edu and www.cclabs.missouri.edu) use the Apache "sucgi" facility. This causes CGI programs stored under your directory ~/www/ with file name ending ".cgi" to execute as your own ID. On some other Web server the script does not execute under your login ID! It executes under the ID of the Web server, typically as user "nobody".

Thus a script that works at the command line may fail under the Web server because:

  • The path for executables or Perl library might be inappropriate. Print $ENV{'PATH'} and @INC to see if there's a difference. Fix it with Perl statements like:
        $ENV{'PATH'} .= ':~myid/bin:~myid/cgibin';
        push @INC,'~myid/lib/perl';
  • File permissions give your ID access don't give the Web server appropriate access.

  •  
     
    [an error occurred while processing this directive]