Apache-PSP

 view release on metacpan or  search on metacpan

lib/Template/PSP.pm  view on Meta::CPAN

}

#########################################
# MISC FUNCTIONS

# checks if file has changed on disk
sub newfile {
    my $file = shift;
    my $mtime = -M "$file";

    if (!defined($Cache{$file}) || $Cache{$file} != $mtime) {
	$Cache{$file} = $mtime;
	return 1;
    }
    return 0;
}

# converts file name into valid package
sub valid_package_name {
    my($string) = @_;
    $string =~ s/([^A-Za-z0-9\/])/sprintf("_%2x",unpack("C",$1))/eg;
    # second pass only for words starting with a digit
    $string =~ s|/(\d)|sprintf("/_%2x",unpack("C",$1))|eg;
    
    # Dress it up as a real package name
    $string =~ s|/|::|g;
    return "ve" . $string;
}


sub count_lines {
    my $text = shift;
    my $pos = 0;
    my $lines;

    while (($pos = index($text, "\n", $pos)) >= 0) {
	$lines++;
	$pos++;
    }
    return $lines;
}


1;

__END__

=head1 NAME

Template::PSP - Process HTML-like files with custom tags and Perl code

=head1 SYNOPSIS

  use Template::PSP;

  my $page_code = Template::PSP::pspload($filename);
  &$page_code();

=head1 DESCRIPTION

Template::PSP allows arbitrary Perl code to be embedded in HTML-like pages. It also provides a framework for creating custom tags using a combination of text and evaluated Perl. 

=head1 AUTHOR

Chris Radcliff, chris@globalspin.com

=head1 SEE ALSO

Apache::PSP

=cut



( run in 1.247 second using v1.01-cache-2.11-cpan-df04353d9ac )