About MartNet MartNet Technical Support
Home Services Support Members Software Contact
Search Support
MartNet WebMail

MartNet WebAdmin

Dialup Access

Domain Name

MartNet News /
  Status Info

NOC / System Status

Support Topics:
 MartNet WebAdmin
 Virtual Hosting
 Web Site Construction
 Unix / Linux
 Internet Chat
 Game Server Services
 Misc. Stuff
 Policies / Legal

 MartNet WebAdmin
 Virtual Hosting
 Game Server Services
 Misc. FAQ's

 Privacy and Security
 Web Development
 Unix / Linux
 Game Server Services
 Misc. Support Links

MartNet Ad

MartNet Policies
Billing Dept.

Check Domain

Programming with Perl
Trouble-shooting and fixing broken Perl scripts

Check to see if the permissions on their script are as follows:

-rwxrwxr-x (775) or -rwxr-xr-x (755)

Run the following command: head -50 'filename' Note: filename is the name of their script.

This will display the first 50 lines of the script. If the file looks like someone took your text file and ran it

through a paper shredder, then you may have not uploaded your script in ASCII or TEXT mode.

Check the first line of your script to see if it is exactly as follows:


Check all file references. Are you setting the variables to the correct file paths. For example:

$mailprog = '/bin/sendmail'

All paths should be full paths to the file. If you have a file in your www directory that you are trying

to reference, then you need to include /usr/dom/'xuser'/www/'filename' in the path to that file.

Also, check to see if you are specifying the correct path to all UNIX commands. Here are a few examples:

sendmail /usr/lib/sendmail

perl /usr/local/bin/perl

date /usr/bin/date

cgi-wrapper /usr/local/etc/httpd/cgi-bin/cgiwrap

You can find the path to any UNIX command by typing:

whereis 'command'

If all of this is correct check the HTML code for that page to see if you are calling the script correctly.

One common mistake is to think that you need to specify a full path to the cgi-bin directory in the URL to the script:

http://'domain name.com'/usr/dom/'xuser'/cgi-bin/'cgi/perl-script'

The above is incorrect. A correct call would look like this:


Keep in mind that server side includes are done in the following manner:

and the name of the HTML file must end with the .shtml extension.






a language by Larry Wall


Practical Extraction and Report Language




Pathologically Eclectic Rubbish Lister


Tom Christiansen

CONVEX Computer Corporation





o What is Perl: features, where to get it, preview


o Data Types: scalars and arrays


o Operators


o Flow Control


o Regular Expressions


o I/O: regular I/O, system functions, directory access, for-

matted I/O


o Functions and Subroutines: built-in array and string func-



o Esoterica: suid scripts, debugging, packages, command line



o Examples


What is Perl?


o An interpreted language that looks a lot like C with built-

in sed, awk, and sh, as well as bits of csh, Pascal, FOR-

TRAN, BASIC-PLUS thrown in.


o Highly optimized for manipulating printable text, but also

able to handle binary data.


o Especially suitable for system management tasks due to in-

terfaces to most common system calls.


o Rich enough for most general programming tasks.


o "A shell for C programmers." [Larry Wall]




o Easy to learn because much derives from existing tools.


o More rapid program development because it's an interpreter


o Faster execution than shell script equivalents.


o More powerful than sed, awk, or sh; a2p and s2p translators

supplied for your old scripts.


o Portable across many different architectures.


o Absence of arbitrary limits like string length.


o Fits nicely into UNIX tool and filter philosophy.


o It's free!



Where to get it


o Any comp.sources.unix archive


o Famous archive servers

o uunet.uu.net

o tut.cis.ohio-state.edu


o Its author, Larry Wall

o jpl-devvax.jpl.nasa.gov


o Perl reference guide (in postscript form) also available

from Ohio State, along with some sample scripts and archives

of the perl-users mailing list.


o USENET newsgroup comp.lang.perl good source for questions,

comments, examples.




o It's not for nothing that perl is sometimes called the

"pathologically eclectic rubbish lister." Before you drown

in a deluge of features, here's a simple example to whet

your appetites that demonstrates the principal features of

the language, all of which have been present since version



while (<>) {

next if /^#/;

($x, $y, $z) = /(S+)s+(ddd)s+(foo|bar)/;

$x =~ tr/a-z/A-Z/;


$z =~ s/foo/fear/ && $scared++;

printf "%s %08x %-10sn", $z, $y, $x

if $seen{$x} > $y;




Data Types


o Basic data types are scalars, indexed arrays of scalars, and

associative arrays of scalars.


o Scalars themselves are either string, numeric, or boolean,

depending on context. Values of 0 (zero) and '' (null

string) are false; all else is true.


o Type of variable determined by leading special character.

o $ scalar

o @ indexed array (lists)

o % associative array

o & function


o All data types have their own separate namespaces, as do la-

bels, functions, and file and directory handles.


Data Types (scalars)


o Use a $ to indicate a scalar value


$foo = 3.14159;


$foo = 'red';


$foo = "was $foo before"; # interpolate variable


$host = `hostname`; # note backticks


($foo, $bar, $glarch) = ('red', 'blue', 'green');


($foo, $bar) = ($bar, $foo); # exchange


Special Scalar Variables


o Special scalars are named with punctuation (except $0). Ex-

amples are


o $0 name of the currently executing script

o $_ default for pattern operators and implicit I/O

o $$ the current pid

o $! the current system error message from errno

o $? status of last `backtick`, pipe, or system

o $| whether output is buffered

o $. the current line number of last input

o $[ array base, 0 by default; awk uses 1

o $< the real uid of the process

o $( the real gid of the process

o $> the effective uid of the process

o $) the effective gid of the process


Data types (arrays)


o Indexed arrays (lists); $ for one scalar element, @ for all

$foo[$i+2] = 3; # set one element to 3

@foo = ( 1, 3, 5 );# init whole array

@foo = ( ) ; # initialize empty array

@foo = @bar; # copy whole @array

@foo = @bar[$i..$i+5]; # copy slice of @array


o $#ARRAY is index of highest subscript, so the script's name

is $0 and its arguments run from $ARGV[0] through

$ARGV[$#ARGV], inclusive.


o Associative (hashed) arrays; $ for one scalar element, % for


$frogs{'green'} += 23; # 23 more green frogs

$location{$x, $y, $z} = 'troll'; # multi-dim array

%foo = %bar; # copy whole %array

@frogs{'green', 'blue', 'yellow'} = (3, 6, 9);


Special Array Variables


o @ARGV command line arguments


o @INC search path for files called with do


o @_ default for split and subroutine parameters


o %ENV the current enviroment; e.g. $ENV{'HOME'}


o %SIG used to set signal handlers


sub trapped {

print STDERR "Interrupted

This Web Site is proudly built upon an Open Source foundation:
Assembled with PHP Powered by Debian Linux Fueled by MySQL
Served by Apache

Home | Services | Support | Members | Software | Contact

MartNet - PO Box 42472 Philadelphia, PA 19101
Copyright 1996 - 2015 MartNet Communications LLC. All Rights Reserved.