Chilkat2 for Perl — Downloads
Chilkat2 for Perl is the Perl-style Chilkat API: the Chilkat2 module, with classes in
the Chilkat2:: namespace (Chilkat2::Http, Chilkat2::JsonObject, …), one
accessor per property ($http->ConnectTimeout(10)), character strings in and out, progress callbacks
you write as closures, perldoc for every class, and an optional RaiseError mode in which a
failed call dies with a Chilkat2::Error. HTTP and REST, email, FTP, SFTP, SSH, zip, encryption,
signatures, certificates, XML, JSON, sockets and more, for Perl 5.26 through 5.44 on Windows (Strawberry
Perl), Linux, Alpine Linux and macOS.
use Chilkat2;, Chilkat2::Http->new, $http->QuickGetStr($url)) is for new
code. The classic module (use chilkat;, chilkat::CkHttp->new(), get_/put_
property methods) is unchanged and remains on the Chilkat Perl downloads page; the two are
separate modules and can be installed side by side. See the differences.
Jump to: Which download? · Windows · Linux · Alpine Linux · macOS · Getting started · The API in brief · Troubleshooting
Documentation & Samples
- 📦 In every download: the documentation of each class as POD —
perldoc Chilkat2,perldoc Chilkat2::Http, … once installed - 📝 Release Notes on the Chilkat blog
Which download do I need?
Perl has no binary interface shared between versions, so each download is built for one Perl version (5.26, 5.28, …, 5.44), for non-threaded or thread-multi perls, and for one OS and CPU architecture. All must match the perl that will load it. Ask that perl:
perl -MConfig -e 'printf "%vd %s %s\n", $^V, $Config{useithreads} ? "thread-multi" : "non-threaded", $Config{archname}' # Linux, macOS
perl -MConfig -e "printf qq(%vd %s\n), $^V, $Config{archname}" :: Windows
A build for another perl refuses to load and says why (see Troubleshooting). The system perl of most Linux distributions is thread-multi; perlbrew and plenv build non-threaded perls by default. More about choosing.
Windows (Strawberry Perl)
- 64-bit, Perl 5.30 – 5.42→ chilkat2-perl-5.xx-x86_64-mingw32
- 32-bit, Perl 5.30, 5.32→ chilkat2-perl-5.xx-x86-mingw32
Strawberry Perl is always thread-multi; there is one Windows build per version.
Linux (glibc)
- Non-threaded→ chilkat2-perl-5.xx-<arch>-linux
- Thread-multi→ chilkat2-perl-thread-multi-5.xx-<arch>-linux
x86_64, aarch64. Debian/Ubuntu, RHEL/Fedora and most other distributions ship a thread-multi perl.
Alpine Linux (musl)
- Non-threaded→ chilkat2-perl-5.xx-<arch>-alpine
- Thread-multi→ chilkat2-perl-thread-multi-5.xx-<arch>-alpine
x86_64, aarch64 (spelled arm64 in the thread-multi names). The glibc builds do not load on Alpine.
macOS
- Non-threaded→ chilkat2-perl-5.xx-<arch>-macosx
- Thread-multi→ chilkat2-perl-thread-multi-5.xx-<arch>-macosx
arm64 (Apple silicon, Perl 5.34 and later), x86_64 (Intel). Homebrew's perl is thread-multi.
Windows (Strawberry Perl)
Each .zip contains the module with a code-signed Chilkat2.dll, linked with the C++ runtime
statically. Getting started →
Linux (x86_64, aarch64)
For glibc-based distributions (Debian/Ubuntu, RHEL/Fedora, SUSE, Arch, Raspberry Pi OS 64-bit, …). Each
.tar.gz contains the module with Chilkat2.so. Alpine Linux uses musl and needs the Alpine
downloads below. Getting started →
Thread-multi — the distributions' system perl
Non-threaded
Alpine Linux (x86_64, aarch64)
Built for musl. Each .tar.gz contains the module with Chilkat2.so.
Getting started →
Non-threaded
Thread-multi
macOS (arm64, x86_64)
Each .tar.gz contains the module with a code-signed Chilkat2.bundle. Apple silicon builds
start at Perl 5.34. Getting started →
Thread-multi — Homebrew's perl
Non-threaded
Getting started
The steps are the same on every operating system (Windows: gmake instead of make, which
Strawberry Perl includes).
-
Download and extract
tar xzf chilkat2-perl-thread-multi-5.40-x86_64-linux.tar.gz # Linux / Alpine / macOS (your file name) # Windows: right-click the .zip → Extract All, or: tar -xf chilkat2-perl-5.40-x86_64-mingw32.zip # Windows 10 and later include tar
macOS only: if the browser added a quarantine attribute, clear it so Gatekeeper does not block the library:
xattr -dr com.apple.quarantine chilkat2-perl-thread-multi-5.40-arm64-macosx
-
What's in the download
chilkat2-perl-<flavor>-<version>-<platform>/ ├─ lib/Chilkat2.pm the module ├─ lib/Chilkat2/Http.pm, … the documentation of each class (perldoc) ├─ lib/auto/Chilkat2/Chilkat2.so the library (Chilkat2.bundle on macOS, Chilkat2.dll on Windows) ├─ Makefile.PL, test.pl install and check; nothing is compiled ├─ README.txt └─ license.pdf, THIRD-PARTY-NOTICES.txt, … and a software bill of materials (chilkat.cdx.json)
-
Try it without installing
From the extracted folder:
perl -Ilib test.pl
test.plloads the module, prints the Chilkat version and round-trips some JSON. If the library was built for another perl, the message says which; see Troubleshooting. -
Install
perl Makefile.PL # checks that the library loads into this perl make make test sudo make install # or: perl Makefile.PL INSTALL_BASE=~/perl5 for a per-user install
Windows:
perl Makefile.PL,gmake,gmake test,gmake install. Alternatively, copy the contents oflib/into a directory in@INC, or pointPERL5LIB(oruse lib) at it. -
Unlock
Chilkat is fully functional for a 30-day trial. Call
UnlockBundleonce when your program starts; any string starts the trial, and your purchased unlock code is used the same way:Chilkat2::Global->new->UnlockBundle('Anything for 30-day trial');
A first program
use strict;
use warnings;
use Chilkat2;
Chilkat2::Global->new->UnlockBundle('Anything for 30-day trial');
my $http = Chilkat2::Http->new(ConnectTimeout => 10); # properties may be set in new()
$http->on(PercentDone => sub {
my ($pct) = @_;
print "$pct%\n";
return 0; # a true value aborts the download
});
my $html = $http->QuickGetStr('https://www.chilkatsoft.com/');
if (!defined $html) {
print $http->LastErrorText, "\n"; # why it failed
exit;
}
print "HTTP ", $http->LastStatus, ", ", length($html), " characters\n";
# Or let failures die, DBI-style: a Chilkat2::Error that stringifies to the LastErrorText
my $json = Chilkat2::JsonObject->new(RaiseError => 1);
eval { $json->LoadFile('config.json'); 1 } or print "failed in ", $@->method, ": $@";
The API in brief
Same classes, same members, same behavior as every other Chilkat product.
| Chilkat2 Perl | Classic Chilkat Perl | |
|---|---|---|
| Loading | use Chilkat2; | use chilkat(); |
| Classes | Chilkat2::Http->new(ConnectTimeout => 30) | chilkat::CkHttp->new() |
| Properties | $http->ConnectTimeout(30); my $t = $http->ConnectTimeout; | $http->put_ConnectTimeout(30); my $t = $http->get_ConnectTimeout(); |
| Methods | $http->QuickGetStr($url) | $http->quickGetStr($url) |
| Failure | returns false / undef, the reason in LastErrorText; or, with RaiseError => 1, dies with a Chilkat2::Error | returns false / undef; read lastErrorText() |
| “Not found” | lookup methods such as $xml->FindChild($path) return undef, never die | returns undef |
| Strings | Perl character strings in and out: length, regexes and :encoding layers just work | UTF-8 bytes; decode('UTF-8', ...) needed |
| Binary data | byte strings (BinData) | also CkByteData |
| Misuse | a wrong argument count or type, a read-only property, an unknown property in new croaks with the caller's file and line | — |
| Progress events | $obj->on(PercentDone => sub {...}, AbortCheck => sub {...}, ProgressInfo => sub {...}) | a Perl subclass of chilkat::CkHttpProgress |
| Documentation | perldoc Chilkat2::Http | online only |
Async (*Async, Task) | not included | included |
| Unlocking | Chilkat2::Global->new->UnlockBundle($code) | chilkat::CkGlobal->new()->UnlockBundle($code) |
Events run during the method call; returning a true value from an AbortCheck or
PercentDone handler aborts the method (it then fails in the usual way), and a die in a handler
aborts it and is re-thrown from the method call. AbortCheck fires every HeartbeatMs
milliseconds, which is how a script limits a long call.
Troubleshooting
Can't locate Chilkat2.pm in @INC- The module is not installed in the perl that runs the script (check with
which perl/where perl), or a per-user install directory is not inPERL5LIB. Chilkat2.so: loadable library and perl binaries are mismatched (got handshake key …, needed …)- The download is for the other flavor: a thread-multi perl needs a
thread-multidownload, a non-threaded perl the one without it (above). Perl API version v5.38.0 of Chilkat2 does not match v5.40.0- The download is for a different Perl version: use the one for your
perl -v(above). Error loading shared library/No such file or directoryon Alpine (or the reverse)- A glibc (Linux) build on Alpine Linux, or an Alpine build on a glibc distribution: use the download for the C library of the system.
- macOS: the library “cannot be opened” or fails a code-signature check
- Clear the download's quarantine attribute:
xattr -dr com.apple.quarantine <extracted folder>. Wide character in argument 1 to Chilkat2::BinData::AppendData- Binary-data methods take byte strings. Encode text first (
Encode::encode('UTF-8', $text)), or use the string methods (AppendString), which take character strings. Chilkat2::Http has no writable property 'ConectTimeout'- Property names are checked: a misspelled name in
newor a call to a read-only property croaks rather than being silently ignored. Can't locate object method "new" via package "Chilkat2::CodeSign"on Linux or macOSCodeSignandScMinidriveruse Windows APIs and exist only in the Windows builds.