CGI-Info

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


- `use ->new() not ::new() to instantiate`

    **Level**: fatal (croak).
    **Cause**: called as `CGI::Info::new()` (double-colon) instead of `CGI::Info->new()`.
    **Action**: change the call-site to use the arrow notation.

- `Logger must be an object with info() and error() methods`

    **Level**: fatal (croak).
    **Cause**: the `logger` argument is not a blessed object, or does not
    implement `info()`, `warn()`, and `error()` methods.
    **Action**: pass a compliant logger such as a [Log::Abstraction](https://metacpan.org/pod/Log%3A%3AAbstraction)-based object.

- `expect has been deprecated, use allow instead`

    **Level**: fatal (croak).
    **Cause**: the removed `expect` parameter was passed to `new()`.
    **Action**: replace `expect => [...]` with `allow => { key => qr/.../ }`.

### Script\_Name

Retrieves the name of the executing CGI script.
This is useful for POSTing,
thus avoiding hard-coded paths into forms.

```perl
    use CGI::Info;

    my $info = CGI::Info->new();
    my $script_name = $info->script_name();
    # ...
    print "<form method=\"POST\" action=$script_name name=\"my_form\">\n";
```

#### Api Specification

##### Input

None.

##### Output

```perl
{
  type => 'string',
  'min' => 1,
  'nomatch' => qr/^[\/\\]/    # Does not return absolute path
}
```

### 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];
    }
```

### Script\_Dir

Returns the file system directory containing the script.

```perl
    use CGI::Info;
    use File::Spec;

    my $info = CGI::Info->new();

    print 'HTML files are normally stored in ', $info->script_dir(), '/', File::Spec->updir(), "\n";

    # or
    use lib CGI::Info::script_dir() . '../lib';
```

### Host\_Name

Return the host-name of the current web server, according to CGI.
If the name can't be determined from the web server, the system's host-name
is used as a fall back.
This may not be the same as the machine that the CGI script is running on,
some ISPs and other sites run scripts on different machines from those
delivering static content.
There is a good chance that this will be domain\_name() prepended with either
'www' or 'cgi'.

```perl
    use CGI::Info;

    my $info = CGI::Info->new();
    my $host_name = $info->host_name();
    my $protocol = $info->protocol();
    # ...
    print "Thank you for visiting our <A HREF=\"$protocol://$host_name\">Website!</A>";
```

### Domain\_Name

Domain\_name is the name of the controlling domain for this website.
Usually it will be similar to host\_name, but will lack the http:// or www prefixes.

Can be called as a class method.

### Cgi\_Host\_Url

Return the URL of the machine running the CGI script.

### Params



( run in 1.446 second using v1.01-cache-2.11-cpan-eb134014566 )