Are You Wasting Time?

I wasted about 3 years when I first started on the internet.

The first website I built was on free web hosting. Never got more than 2 visitors a day and never made a penny.

Then I tried a web host that I didn't know anything about.
OOPS!
A BIG mistake and another waste of valuable time. My website was down half the time and when I tried to leave they stole my domain name.

I don't want you to make the same mistakes I made. That's why I only recommend top quality, dependable web hosting providers.

I recommend 3 in different price ranges:
Yahoo SB
$11.95 to $39.95

HostPapa
$5.95 to $7.95

CafW Hosting
$4.19 to $10.95

I recommend all 3 for quality and dependability.


CGI Scripts
to Create a Website with Interactive Features

Sorting the Database

There are 2 sort routines presented here. The first is a simple ascii code sort that sorts the database by name. The second is used when you need to sort numerically. An ascii sort would sort the numbers 1,2,12,32,300 as 1,12,2,300,32. The numerical sort below would sort them correctly by numeric value.


sort_names.pl

#!/usr/bin/perl
#sort_names.pl
open (INFO,"names_file.txt");
@array=<INFO>;
close (INFO);

@sortedarray=sort(@array);

print "Content-type:text/html\n\n"; #Follow with blank line

print "<html>\n";
print "<head><title></title></head>\n";
print "<body>\n";

foreach $line (@sortedarray){
($last,$first)=split(/\|/,$line);
print "$first $last<br>\n";
}

print "</body>\n";
print "</html>\n";

Test these Scripts

sort_numbers.pl

#!/usr/bin/perl
#sort_numbers.pl
open(INFO, "records_file.txt"); # Open db for reading and display
@array=<INFO>;
close (INFO);

print "Content-type:text/html\n\n"; #Follow with blank line

print "<html>\n";
print "<head><title></title></head>\n";
print "<body>\n";
print "<h4>Sorted by Number</h4>\n";

foreach $line(sort byNUM @array){
chomp($line);
($last,$first,$record)=split(/\|/,$line);
print "$record $first $last<br>\n";
}

print "</body>\n";
print "</html>\n";

#Sorting Subroutine
sub byNUM {
@a=split(/\|/,$a);
@b=split(/\|/,$b);
$a[2] <=> $b[2];
}

records_file.txt

Bunyan|Paul|3
SimpSon|Bart|12
Anderson|Pamela|22
Bush|George|1

Note: If the scripts don't work:
1...Check the shebang line and make sure it is the path recommended by your web host to access the perl interpreter on your server.
2...Be sure to use the Chmod function on your ftp client or file manager to change the permissions of the script to 755