CGI-Info

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


### Script\_Path

Finds the full path name of the script.

```perl
    use CGI::Info;

    my $info = CGI::Info->new();
    my $fullname = $info->script_path();
    my @statb = stat($fullname);

    if(@statb) {
            my $mtime = localtime $statb[9];
            print "Last-Modified: $mtime\n";
            # TODO: only for HTTP/1.1 connections
            # $etag = Digest::MD5::md5_hex($html);
            printf "ETag: \"%x\"\n", $statb[9];
    }
```

lib/CGI/Info.pm  view on Meta::CPAN

}

=head2 script_path

Finds the full path name of the script.

	use CGI::Info;

	my $info = CGI::Info->new();
	my $fullname = $info->script_path();
	my @statb = stat($fullname);

	if(@statb) {
		my $mtime = localtime $statb[9];
		print "Last-Modified: $mtime\n";
		# TODO: only for HTTP/1.1 connections
		# $etag = Digest::MD5::md5_hex($html);
		printf "ETag: \"%x\"\n", $statb[9];
	}
=cut

t/script.t  view on Meta::CPAN

	my $i = new_ok('CGI::Info');
	ok(File::Spec->file_name_is_absolute($i->script_path()));
	ok($i->script_path() =~ /.+script\.t$/);
	cmp_ok($i->script_name(), 'eq', 'script.t', 'script_name() works');
	ok($i->script_path() eq File::Spec->catfile($i->script_dir(), $i->script_name()));
	ok($i->script_path() eq File::Spec->catfile(CGI::Info::script_dir(), $i->script_name()));
	# Check calling twice return path
	ok($i->script_name() eq 'script.t');

	ok(-f $i->script_path());
	my @statb = stat($i->script_path());
	ok(defined($statb[9]));

	# Test full path given as the name of the script
	$ENV{'SCRIPT_NAME'} = $i->script_path();
	$i = new_ok('CGI::Info');
	ok(File::Spec->file_name_is_absolute($i->script_path()));
	ok($i->script_path() =~ /.+script\.t$/);
	if($^O eq 'MSWin32') {
		TODO: {
			local $TODO = 'Absolute path test needs to be done on Windows';



( run in 4.174 seconds using v1.01-cache-2.11-cpan-7a24b6fcba5 )