---
product: Chilkat
product_version: 11.7.0
language: perl2
language_label: Chilkat2 Perl
document: language guide
---
> Chilkat 11.7.0 · language=perl2 · this file: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/perl2/guide.md`
> Class pages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/perl2/classes/<Class>.md`

# Chilkat for Chilkat2 Perl — language guide — v11.7.0

> This guide has only generated sections so far. The class pages carry the per-member detail.

## Object creation, unlocking and error handling

**Object Creation**

```perl
use Chilkat2;

my $glob = Chilkat2::Global->new;
# or set properties (and RaiseError) at creation:
# my $glob = Chilkat2::Global->new(VerboseLogging => 1, RaiseError => 1);
```

`my $glob = Chilkat2::Global->new(Property => $value, ...);`

Creates the object. The optional pairs set writable properties (and `RaiseError`) in order, as if set one by one; an unknown or read-only name croaks. `use Chilkat2;` loads every class; the `Chilkat2/Global.pm` file holds only this class's documentation (`perldoc Chilkat2::Global`).

Perl frees the object when its last reference goes (`undef $glob`, or the variable going out of scope); there is nothing to close. Objects returned by methods are independent and freed the same way. The class may be subclassed (`use parent -norequire, 'Chilkat2::Global';`): an object is a blessed hash reference whose hash is free for the subclass's own fields.

`my $boolVal = $glob->RaiseError; $glob->RaiseError($boolVal);`

When false (the default), a method that fails returns false (or `undef`), and the reason is in `LastErrorText`. When true, it dies with a `Chilkat2::Error` instead, as DBI does with its `RaiseError`. Objects returned by a method inherit the value of the object that returned them.

**Errors**

A `Chilkat2::Error` stringifies to the failed call's full `LastErrorText`, and has the methods `text`, `class` (`'Chilkat2::Global'`), `method` (the method name) and `object`. Methods that look something up and find nothing return `undef` without dying (each such method says so), methods that answer a question (`HasMember`, `IsUnlocked`, ...) return a plain boolean, and property reads and writes never fail for Chilkat reasons.

Misuse always croaks, with your file and line, whatever `RaiseError` is: a wrong number of arguments, a reference or `undef` where a string or number is expected, an object of the wrong class, an out-of-range integer, a string containing a NUL character, a wide character in a byte string, or a write to a read-only property.

Strings are Perl character strings in both directions (`length`, regexes and `:encoding` layers see characters); binary data (`BinData`) is a byte string. Unlocking: call `Chilkat2::Global->new->UnlockBundle('...')` once at startup.

Literals in Chilkat2 Perl: true is `1`, false is `0`, null/none is `undef`.

## Classes

[Class index for Chilkat2 Perl](https://www.chilkatsoft.com/ai-docs/v/11.7.0/perl2/index.md)
