I have copied all the code in http://www.gossamer-threads.com/scripts/resources/Detailed/877.html
CGI ERROR
==========================================
Error Message : fatal error: /home/mysite/cgi-bin/dir/admin/Template.pm has too many errors.
Script Location : /home/mysite/cgi-bin/dir/admin/nph-build.cgi
Perl Version : 5.00503
---Parser---
sub parse {
# ---------------------------------------------------------------
# Parses a template.
#
my ($self, $template) = @_;
my $begin = $self->{'begin'} || quotemeta('<%');
my $end = $self->{'end'} || quotemeta('%>');
exists $self->{'templates'}{$template} or ($self->load_template($template) or return undef);
exists $self->{'vars'} or ("error ('NONAMESPACE') and return undef);
$self->{'parsed'}{$template} = '';
my $temp = $self->{'templates'}{$template};
# Parse includes, do this first so that the includes can include
# template tags.
$temp =~ s#$begin\s*include\s*(.+?)\s*$end#
if (exists $self->{'inc'}{$1}) { $self->{'inc'}{$1}; }
else {
if (open (INC, "${$self}{'ROOT'}/$1")) {
$self->{'inc'}{$1} = join ("", <INC> );
close INC;
$self->{'inc'}{$1};
}
else {
"Can't find file: ${$self}{'ROOT'}/$1";
}
}
#goe;
# Now go line by line and strip out the unwanted stuff looking for
# if and ifnot tags.
my @lines = split /\n/, $temp;
$temp = ''; my @go = (1,1); my $depth = 1; my $line = '';
LINE: foreach $line (@lines) {
# Init the previous, variable and more strings.
my ($prev, $var, $neg, $more, $orig, $full_comp, $comp, $val, $key) = ('') x 9;
my $result = 0;
my $ret = '';
# Check for if tags.
$line =~ s/^((.*?)$begin\s*(if(?:not)?|unless)\s+(.+?)(\s*(<|<=|>|>=|\slt\s|\sle\s|\sgt\s|\sge\s|\seq\s|==?)\s*(.+?))?$end(.*))/
($orig, $prev, $neg, $var, $full_comp, $comp, $val, $more) = ($1, $2, $3 ne "if", $4, $5, $6, $7, $8);
if ($prev !~ m,$begin\s*endif\s*$end,og) {
defined $val or ($val = '');
$val =~ tr,'",,d;
$val = $self->_check_func ($val, $strict, 1);
$key = $self->_get_value ($var, 0); # No strict as we are comping.
$go[$depth] and ($temp .= $prev);
if (!$full_comp) {
if ($neg) { $key ? ($go[++$depth] = 0) : ($go[++$depth] = $go[$depth]) and ($ret = ''); }
else { $key ? ($go[++$depth] = $go[$depth]) : ($go[++$depth] = 0) and ($ret = ''); }
}
else {
CASE: {
$comp =~ s,^\s+|\s+$,,g;
($comp eq 'eq') and $result = ($key eq $val), last CASE;
($comp eq '=' or $comp eq '==')
and $result = ($key == $val), last CASE;
($comp eq 'lt') and $result = ($key lt $val), last CASE;
($comp eq 'le') and $result = ($key le $val), last CASE;
($comp eq 'gt') and $result = ($key gt $val), last CASE;
($comp eq 'ge') and $result = ($key ge $val), last CASE;
($comp eq '>' ) and $result = ($key > $val), last CASE;
($comp eq '>=') and $result = ($key >= $val), last CASE;
($comp eq '<' ) and $result = ($key < $val), last CASE;
($comp eq '<=') and $result = ($key <= $val), last CASE;
};
if ($neg) { $result ? ($go[++$depth] = 0) : ($go[++$depth] = $go[$depth]) and ($ret = ''); }
else { $result ? ($go[++$depth] = $go[$depth]) : ($go[++$depth] = 0) and ($ret = ''); }
}
$ret;
}
else {
$more = '';
$orig;
}
/oe;
if ($more) { $line = $more; redo LINE; }
# Check for endif tags.
$line =~ s/^(.*?)$begin\s*endif\s*$end(.*)/
($prev, $more) = ($1, $2);
$go[$depth] and ($temp .= $prev);
$go[$depth--] = 1;
"";
/oe;
if ($more) { $line = $more; redo LINE; }
# Add the content..
$go[$depth] and ($temp .= "$line\n");
}
# Replace the special variables, we allow code ref mapping.
$temp =~ s/$begin\s*(.+?)\s*$end/
if (exists $self->{'vars'}{$1}) {
ref ($self->{'vars'}{$1}) eq 'CODE' ?
"{$self->{'vars'}{$1}}($self->{'vars'}) : $self->{'vars'}{$1};
}
else { "Unkown Tag: $1"; }
/goe;
$self->{'parsed'}{$template} = $temp;
return $self->{'parsed'}{$template};
}
Help again!!
CGI ERROR
==========================================
Error Message : fatal error: /home/mysite/cgi-bin/dir/admin/Template.pm has too many errors.
Script Location : /home/mysite/cgi-bin/dir/admin/nph-build.cgi
Perl Version : 5.00503
---Parser---
sub parse {
# ---------------------------------------------------------------
# Parses a template.
#
my ($self, $template) = @_;
my $begin = $self->{'begin'} || quotemeta('<%');
my $end = $self->{'end'} || quotemeta('%>');
exists $self->{'templates'}{$template} or ($self->load_template($template) or return undef);
exists $self->{'vars'} or ("error ('NONAMESPACE') and return undef);
$self->{'parsed'}{$template} = '';
my $temp = $self->{'templates'}{$template};
# Parse includes, do this first so that the includes can include
# template tags.
$temp =~ s#$begin\s*include\s*(.+?)\s*$end#
if (exists $self->{'inc'}{$1}) { $self->{'inc'}{$1}; }
else {
if (open (INC, "${$self}{'ROOT'}/$1")) {
$self->{'inc'}{$1} = join ("", <INC> );
close INC;
$self->{'inc'}{$1};
}
else {
"Can't find file: ${$self}{'ROOT'}/$1";
}
}
#goe;
# Now go line by line and strip out the unwanted stuff looking for
# if and ifnot tags.
my @lines = split /\n/, $temp;
$temp = ''; my @go = (1,1); my $depth = 1; my $line = '';
LINE: foreach $line (@lines) {
# Init the previous, variable and more strings.
my ($prev, $var, $neg, $more, $orig, $full_comp, $comp, $val, $key) = ('') x 9;
my $result = 0;
my $ret = '';
# Check for if tags.
$line =~ s/^((.*?)$begin\s*(if(?:not)?|unless)\s+(.+?)(\s*(<|<=|>|>=|\slt\s|\sle\s|\sgt\s|\sge\s|\seq\s|==?)\s*(.+?))?$end(.*))/
($orig, $prev, $neg, $var, $full_comp, $comp, $val, $more) = ($1, $2, $3 ne "if", $4, $5, $6, $7, $8);
if ($prev !~ m,$begin\s*endif\s*$end,og) {
defined $val or ($val = '');
$val =~ tr,'",,d;
$val = $self->_check_func ($val, $strict, 1);
$key = $self->_get_value ($var, 0); # No strict as we are comping.
$go[$depth] and ($temp .= $prev);
if (!$full_comp) {
if ($neg) { $key ? ($go[++$depth] = 0) : ($go[++$depth] = $go[$depth]) and ($ret = ''); }
else { $key ? ($go[++$depth] = $go[$depth]) : ($go[++$depth] = 0) and ($ret = ''); }
}
else {
CASE: {
$comp =~ s,^\s+|\s+$,,g;
($comp eq 'eq') and $result = ($key eq $val), last CASE;
($comp eq '=' or $comp eq '==')
and $result = ($key == $val), last CASE;
($comp eq 'lt') and $result = ($key lt $val), last CASE;
($comp eq 'le') and $result = ($key le $val), last CASE;
($comp eq 'gt') and $result = ($key gt $val), last CASE;
($comp eq 'ge') and $result = ($key ge $val), last CASE;
($comp eq '>' ) and $result = ($key > $val), last CASE;
($comp eq '>=') and $result = ($key >= $val), last CASE;
($comp eq '<' ) and $result = ($key < $val), last CASE;
($comp eq '<=') and $result = ($key <= $val), last CASE;
};
if ($neg) { $result ? ($go[++$depth] = 0) : ($go[++$depth] = $go[$depth]) and ($ret = ''); }
else { $result ? ($go[++$depth] = $go[$depth]) : ($go[++$depth] = 0) and ($ret = ''); }
}
$ret;
}
else {
$more = '';
$orig;
}
/oe;
if ($more) { $line = $more; redo LINE; }
# Check for endif tags.
$line =~ s/^(.*?)$begin\s*endif\s*$end(.*)/
($prev, $more) = ($1, $2);
$go[$depth] and ($temp .= $prev);
$go[$depth--] = 1;
"";
/oe;
if ($more) { $line = $more; redo LINE; }
# Add the content..
$go[$depth] and ($temp .= "$line\n");
}
# Replace the special variables, we allow code ref mapping.
$temp =~ s/$begin\s*(.+?)\s*$end/
if (exists $self->{'vars'}{$1}) {
ref ($self->{'vars'}{$1}) eq 'CODE' ?
"{$self->{'vars'}{$1}}($self->{'vars'}) : $self->{'vars'}{$1};
}
else { "Unkown Tag: $1"; }
/goe;
$self->{'parsed'}{$template} = $temp;
return $self->{'parsed'}{$template};
}
Help again!!