Apache-EmbeddedPerl-Lite

 view release on metacpan or  search on metacpan

Lite.pm  view on Meta::CPAN

  input:	class name,	(a scalar, not a ref)
		request handle

  return:	Apache response code or undef

  handler is not exported.

Expected Codes:

	  0	OK
	404	File Not Found
	500	Server Error

  404 could not find, open, etc... file
  500 missing closing embedded perl bracket
      embedded perl has an error

When a 500 error is returned, a warning will be issued to STDERR providing
details about the error.
	
A ContentType header will not be sent unless the type is specified as
follows:

	PerlSetVar	ContentType	text/html

Lite.pm  view on Meta::CPAN

  {	local $SIG{__WARN__} = sub {};
	eval;
  }
}

sub embedded {
  my ($class,$r,$file,@args) = @_;
  my $lineno = 0;
  local *F;
  my $line;
  (-e $file && open(F,$file)) or return 404;
READLINE:
  while (defined ($line = <F>)) {
    $lineno++;
    if ($line =~ /^\s*\<\!--\s+perl\s*/) {
      (my $perl = $0) =~ s/::/_/g;
      $perl =~ s/([^a-zA-Z0-9_])/sprintf("%02X",ord($1))/seg;
      $perl = 'package '. __PACKAGE__ .'::anon::'. $perl .";\nno strict;\n";
      $perl .= "use diagnostics;\n" if exists $INC{'diagnostics.pm'};
      my $start = $lineno;
      while (defined ($line = <F>)) {

README  view on Meta::CPAN

      input:        class name,     (a scalar, not a ref)
                    request handle

      return:       Apache response code or undef

      handler is not exported.

    Expected Codes:

              0     OK
            404     File Not Found
            500     Server Error

      404 could not find, open, etc... file
      500 missing closing embedded perl bracket
          embedded perl has an error

    When a 500 error is returned, a warning will be issued to STDERR
    providing details about the error.

    A ContentType header will not be sent unless the type is specified as
    follows:

            PerlSetVar      ContentType     text/html

t/nofile.t  view on Meta::CPAN

	}
}

@ISA = qw( Apache::EmbeddedPerl::TestPackage::Alone );

my $r = bless {}, __PACKAGE__;
{
	local $SIG{__WARN__} = sub { $warn .= $_[0] };

	$rv = embedded(__PACKAGE__,$r,'testfiles/'. $file);
	my $exp = 404;
	print "got: $rv, exp: $exp\nnot "
		unless $rv == $exp;
	&ok;

	$exp = q||;
	print "got:\n$warn\nexp:\n$exp\nnot "
		unless $warn eq $exp;
	&ok;

	$exp = '';



( run in 0.477 second using v1.01-cache-2.11-cpan-39bf76dae61 )