[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] A little help please



I've wrote a program that will read in one file and write to another. The
first file contains the following

unknown||Grego
John||Barlett
unknown||Wilson
Pearl||Taylor
unknown
unknown||McCoy

I'm ony interested in the unknowns with last names. As you can see, it will
work at the command line but when I run it through a browser it will only
print the htmlheader. What am I doing wrong?

alan :)


***********************************************************************
#! /usr/local/bin/perl

sub htmlheader {
        print "<HTML>\n";
        print "<HEAD>\n";
        print "<TITLE>Family Tree Names</TITLE>\n";
        print "</HEAD>\n";
        print "<BODY>\n";
        print "<PRE>\n";
}

sub htmlfooter {
        print "</PRE>\n";
        print "</BODY>\n";
        print "</HTML>\n";
}

print "Content-type: text/html\n\n";

&htmlheader;

$count = 0;

if(open(INFILE,"will3.txt") || die("Cannot open will3.txt")) {
		open(OUTFILE,">will4.txt") || die("Cannot open will3.txt");
		while (<INFILE>) {
		@field = split /\|\|/, $_;

	chomp($field[0],$field[1],$field[2],$field[3],$field[4],$field[5]);
# Assign all fields to an array
				if($field[0] =~ /unknown/ && $field[1] eq "") {
					$unknowns++;
				} elsif ($field[0] =~ /unknown/ &&
$field[1] =~ /^[a-zA-Z]/) {
					$lastname = $field[1];
					$firstname = $field[0];
					$hardreturn = "\n";
					@fields = ($lastname, $firstname);
					@fields = sort(@fields);
					$array = join("||", @fields);
					print "$array\n";
					print (OUTFILE ("$array\n"));
					$unknown_names++;
				}

	}
	close(INFILE);
	close(OUTFILE);
}

print "<B>There are a total of $unknowns unknown individuals in the family
trees</B>\n";
print "<B>There are a total of $unknown_names unknown individuals with
family names in the family trees</B>\n";






&htmlfooter;


1;



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org