Tar Chilkat2 Perl Reference Documentation
Chilkat2::Tar
Current Version: 11.7.0
Markdown version of this page for AI tools (v 11.7.0) · all AI docs
Chilkat.Tar
Add files or directory trees and write standard TAR output, with control
over archive paths, directory handling, and write format.
Work with common compressed archive forms such as
Inspect archive entries, verify archive structure, and produce XML
listings for display, logging, or programmatic processing.
Extract entire archives or selected entries, including workflows that
extract matching files directly to memory or
Include or exclude files using filters, control relative paths in the
archive, and manage how entries are restored during extraction.
Preserve or override UNIX-style permissions and create Debian
For an extended overview, see
Tar Class Overview.
Create, list, verify, filter, and extract TAR archives and compressed TAR formats.
Chilkat.Tar creates, verifies, lists, and extracts TAR archives,
including compressed TAR formats such as .tar.gz,
.tgz, .tar.bz2, and .tar.Z. It
supports adding individual files and directory trees, controlling archive
paths, preserving or overriding file permissions, filtering included or
extracted files, extracting from memory, extracting selected entries to
memory or BinData, producing XML listings, and creating Debian
.deb package archives from control and data tarballs.
Create TAR archives
Compressed TAR formats
.tar.gz,
.tgz, .tar.bz2, and .tar.Z.
List and verify contents
Selective extraction
BinData.
Filters and paths
Permissions and packages
.deb package archives from control and data tarballs.
Tar when the data is a TAR archive or a compressed TAR
archive. Configure the archive paths, filters, permissions, and compression
format, then create, list, verify, or extract the archive as needed. Use
Chilkat.Zip for ZIP archives, Chilkat.Gzip for a
single GZIP stream, and Chilkat.Compression for raw compression
operations.
Object Creation
use Chilkat2;
my $tar = Chilkat2::Tar->new;
# or set properties (and RaiseError) at creation:
# my $tar = Chilkat2::Tar->new(VerboseLogging => 1, RaiseError => 1);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/Tar.pm file holds only this class's documentation (perldoc Chilkat2::Tar).
Perl frees the object when its last reference goes (undef $tar, 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::Tar';): an object is a blessed hash reference whose hash is free for the subclass's own fields.
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::Tar'), 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.
Properties
CaptureXmlListing
my $boolVal = $tar->CaptureXmlListing;
$tar->CaptureXmlListing($boolVal);
Controls whether extraction methods also capture an XML inventory of the archive. When set to 1, methods such as Untar, UntarGz, UntarBz2, and UntarZ store the listing in XmlListing. The XML has the same structure as the string returned by ListXml. The default is 0.
CaptureXmlListing and SuppressOutput to 1 before an untar operation to scan the archive and obtain its XML listing without writing archive entries to disk.Charset
my $strVal = $tar->Charset;
$tar->Charset($strVal);
Specifies the character encoding used to decode filenames stored in a TAR archive during extraction. The default is utf-8, which is normally appropriate for modern archives.
This property affects archive entry names only. It does not convert or otherwise alter the contents of extracted files. TAR archives written by the WriteTar* methods store filenames as UTF-8.
DebugLogFilePath
my $strVal = $tar->DebugLogFilePath;
$tar->DebugLogFilePath($strVal);
If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.
Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.
Possible causes of hangs include:
- A timeout property set to 0, indicating an infinite timeout.
- A hang occurring within an event callback in the application code.
- An internal bug in the Chilkat code causing the hang.
DirMode
my $intVal = $tar->DirMode;
$tar->DirMode($intVal);
Specifies the UNIX permission bits written to the TAR header for directory entries created by the WriteTar* methods. The default is octal 0755, which represents rwxr-xr-x.
DirPrefix
my $strVal = $tar->DirPrefix;
$tar->DirPrefix($strVal);
Specifies a path prefix to prepend to entries when a TAR archive is created. For example, setting this property to subdir1 causes an entry such as report.txt to be stored as subdir1/report.txt.
The prefix changes only the path stored in the archive; it does not rename or move the source file on disk.
AddFile2 explicitly supplies the complete path within the archive, so DirPrefix is not applied to files added by that method.FileMode
my $intVal = $tar->FileMode;
$tar->FileMode($intVal);
Specifies the UNIX permission bits written to the TAR header for ordinary file entries created by the WriteTar* methods. The default is octal 0644, which represents rw-r--r--.
ScriptFileMode instead, allowing executable permissions to be recorded separately.GroupId
my $intVal = $tar->GroupId;
$tar->GroupId($intVal);
Specifies the numeric group identifier (GID) written to TAR headers when an archive is created. The default value is 1000.
GroupName
my $strVal = $tar->GroupName;
$tar->GroupName($strVal);
Specifies the group name written to TAR headers when an archive is created. By default, Chilkat uses the username of the account running the application.
GroupId. Extraction tools and operating systems may give different precedence to these fields.HeartbeatMs
my $intVal = $tar->HeartbeatMs;
$tar->HeartbeatMs($intVal);
Specifies the approximate interval, in milliseconds, between AbortCheck event callbacks during supported long-running operations. The default is 0, which disables periodic AbortCheck callbacks.
LastErrorHtml
my $strVal = $tar->LastErrorHtml;
Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastErrorText
my $strVal = $tar->LastErrorText;
Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
LastErrorXml
my $strVal = $tar->LastErrorXml;
Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastMethodSuccess
my $boolVal = $tar->LastMethodSuccess;
$tar->LastMethodSuccess($boolVal);
Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.
MatchCaseSensitive
my $boolVal = $tar->MatchCaseSensitive;
$tar->MatchCaseSensitive($boolVal);
Controls whether the patterns in MustMatch and MustNotMatch are matched case-sensitively. The default is 0.
MustMatch
my $strVal = $tar->MustMatch;
$tar->MustMatch($strVal);
Specifies an inclusion pattern applied when creating or extracting TAR archives, including compressed TAR formats. A candidate path is included or extracted only when it matches this pattern. The default is an empty string, which permits all paths.
The pattern may contain zero or more asterisks (*), where each asterisk matches zero or more characters. For example, *.txt selects paths ending in .txt. Case handling is controlled by MatchCaseSensitive.
MustMatch and MustNotMatch are set, a path must satisfy the inclusion pattern and must not satisfy the exclusion pattern.MustNotMatch
my $strVal = $tar->MustNotMatch;
$tar->MustNotMatch($strVal);
Specifies an exclusion pattern applied when creating or extracting TAR archives, including compressed TAR formats. A candidate path that matches this pattern is skipped. The default is an empty string, which excludes nothing.
The pattern may contain zero or more asterisks (*), where each asterisk matches zero or more characters. For example, *.obj skips paths ending in .obj. Case handling is controlled by MatchCaseSensitive.
MustMatch does not override a match in MustNotMatch.NoAbsolutePaths
my $boolVal = $tar->NoAbsolutePaths;
$tar->NoAbsolutePaths($boolVal);
Controls whether absolute archive paths are converted to relative paths during extraction. When 1, a leading / or \ is removed before the entry is written. The default is 1.
NumDirRoots
my $intVal = $tar->NumDirRoots;
Returns the number of directory roots currently registered for archive creation by calls to AddDirRoot and AddDirRoot2. Individual files added with AddFile or AddFile2 are not included in this count.
Use zero-based indexes from 0 through NumDirRoots - 1 with GetDirRoot.
PercentDoneScale
my $intVal = $tar->PercentDoneScale;
$tar->PercentDoneScale($intVal);
Specifies the value reported by PercentDone when an eligible operation is 100% complete. The default is 100. Increasing the scale allows finer-grained integer progress values; for example, a scale of 1000 allows 453 to represent 45.3%.
The value is clamped to the range 10 through 100000. This property is available only in environments that support event callbacks, and only methods for which measurable progress is available emit percentage updates.
ScriptFileMode
my $intVal = $tar->ScriptFileMode;
$tar->ScriptFileMode($intVal);
Specifies the UNIX permission bits written to TAR headers for shell-script files recognized by extensions such as .sh, .csh, .bash, and .bsh. The default is octal 0755, which records executable permissions.
SuppressOutput
my $boolVal = $tar->SuppressOutput;
$tar->SuppressOutput($boolVal);
Controls whether untar operations write extracted files and directories to the filesystem. When 1, methods such as Untar, UntarGz, UntarBz2, and UntarZ scan the archive without producing extracted output. The default is 0.
CaptureXmlListing to obtain an XML listing without extracting the archive.UntarCaseSensitive
my $boolVal = $tar->UntarCaseSensitive;
$tar->UntarCaseSensitive($boolVal);
Deprecated. Use MatchCaseSensitive instead.
Until this property is removed, reading or setting it has the same effect as reading or setting MatchCaseSensitive.
UntarDebugLog
my $boolVal = $tar->UntarDebugLog;
$tar->UntarDebugLog($boolVal);
Controls whether untar methods add per-entry extraction details to LastErrorText, LastErrorXml, and LastErrorHtml. The default is 0.
UntarDiscardPaths
my $boolVal = $tar->UntarDiscardPaths;
$tar->UntarDiscardPaths($boolVal);
Controls whether directory components from archive entry names are discarded during extraction. When 1, each file is written directly into UntarFromDir rather than recreating the archived directory tree. The default is 0.
UntarFromDir
my $strVal = $tar->UntarFromDir;
$tar->UntarFromDir($strVal);
Specifies the destination directory for extraction. The default is ., meaning the current working directory of the calling process.
When UntarDiscardPaths is 0, archived subdirectories are recreated beneath this directory. When it is 1, extracted files are placed directly in this directory.
UntarMaxCount
my $intVal = $tar->UntarMaxCount;
$tar->UntarMaxCount($intVal);
Limits the number of matching entries extracted by an untar operation. The default is 0, which means no maximum.
For example, set MustMatch to select a particular path and set UntarMaxCount to 1 to stop after the first matching entry is extracted.
UserId
my $intVal = $tar->UserId;
$tar->UserId($intVal);
Specifies the numeric user identifier (UID) written to TAR headers when an archive is created. The default value is 1000.
UserName
my $strVal = $tar->UserName;
$tar->UserName($strVal);
Specifies the user name written to TAR headers when an archive is created. By default, Chilkat uses the username of the account running the application.
UserId. Their interpretation depends on the extracting tool and destination system.VerboseLogging
my $boolVal = $tar->VerboseLogging;
$tar->VerboseLogging($boolVal);
If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.
Version
my $strVal = $tar->Version;
WriteFormat
my $strVal = $tar->WriteFormat;
$tar->WriteFormat($strVal);
Specifies the TAR header format used by the WriteTar* methods. The default is gnu. Supported values are:
| Value | Use |
|---|---|
gnu | GNU TAR format and extensions. This is the Chilkat default and supports archive metadata beyond classic ustar limits. |
pax | POSIX pax extended format. It is designed to represent long names and additional metadata through extensible records. |
ustar | POSIX ustar format. It is broadly interoperable but has stricter limits on path lengths and metadata fields. |
ustar when compatibility with simple TAR readers is the priority and the archive fits its limits. Use pax for portable extended metadata, or retain gnu when GNU TAR compatibility is expected.XmlListing
my $strVal = $tar->XmlListing;
$tar->XmlListing($strVal);
Contains the XML listing captured by the most recent untar operation for which CaptureXmlListing was 1. The XML structure is the same as the output from ListXml.
Methods
AddDirRoot
# $success is true or false
my $success = $tar->AddDirRoot($dirPath);
Adds the directory tree at $dirPath to the set of sources used by the next WriteTar* operation. Call this method multiple times to include multiple directory trees in one archive.
Use AddDirRoot2 when the tree should appear beneath an explicit prefix inside the archive.
ClearDirRootsAndFiles is called.Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
AddDirRoot2
# $rootPath is a string
# $success is true or false
my $success = $tar->AddDirRoot2($rootPrefix, $rootPath);
Adds the directory tree at $rootPath to the archive-creation source list and stores its entries beneath the archive prefix supplied in $rootPrefix. Call this method multiple times, or combine it with AddDirRoot, before calling a WriteTar* method.
$rootPrefix should be a relative archive path such as abc/123 and should not end with /. If DirPrefix is also set, DirPrefix is applied first.
DirPrefix = "package" and rootPrefix = "assets", files from this root are stored beneath package/assets/.Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
AddFile
# $success is true or false
my $success = $tar->AddFile($path);
Adds the local file at $path to the set of sources used by the next WriteTar* operation. Call AddFile, AddFile2, and the directory-root methods as needed before writing a single archive.
Use AddFile2 when the path stored inside the TAR must be specified independently of the source file path.
ClearDirRootsAndFiles is called.Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
AddFile2
# $pathWithinTar is a string
# $success is true or false
my $success = $tar->AddFile2($filePath, $pathWithinTar);
Adds the local file at $filePath to the archive-creation source list and stores it using the exact archive path supplied in $pathWithinTar. This allows the source path and the path visible inside the TAR to differ.
Call this method as many times as needed, optionally together with the other file and directory-root methods, before calling a single WriteTar* method.
$pathWithinTar already specifies the path within the TAR, DirPrefix does not modify entries added by this method. Use forward slashes and a relative path for portable archive names.Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
ClearDirRootsAndFiles
my $success = $tar->ClearDirRootsAndFiles();
Removes all files and directory roots previously registered by AddDirRoot, AddDirRoot2, AddFile, and AddFile2.
Call this method before building a different archive with the same Tar object when the earlier source list should not be reused.
Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
CreateDeb
# $dataPath is a string
# $debPath is a string
# $success is true or false
my $success = $tar->CreateDeb($controlPath, $dataPath, $debPath);
Creates a Debian binary package at $debPath from the prepared control archive at $controlPath and data archive at $dataPath. The inputs are typically named control.tar.gz and data.tar.gz, or use another compression form accepted by the target Debian tooling.
.deb file is an ar archive containing a debian-binary format marker, a control.tar.* member for package metadata and maintainer scripts, and a data.tar.* member for the installed filesystem payload.Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
GetDirRoot
# $str is a string or undef
my $str = $tar->GetDirRoot($index);
Returns a directory root previously added with AddDirRoot or AddDirRoot2. $index is a zero-based index.
Valid indexes range from 0 through NumDirRoots - 1. For example, after two roots are added, GetDirRoot(0) returns the first and GetDirRoot(1) returns the second.
Returns undef on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
ListXml
# $str is a string or undef
my $str = $tar->ListXml($tarPath);
Scans the uncompressed TAR archive at $tarPath and returns an XML description of its files, directories, and archive metadata. The archive is not extracted.
CaptureXmlListing. Set SuppressOutput as well when no files should be written.Returns undef on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
Untar
# $n is an integer
my $n = $tar->Untar($tarPath);
Extracts the uncompressed TAR archive at $tarPath into the directory specified by UntarFromDir. Archived directory trees are recreated unless UntarDiscardPaths is 1.
Returns the number of files and directories extracted, or -1 if the operation fails. Extraction is also affected by the matching, path-safety, count-limit, listing, and output-suppression properties of this object.
.tar archive is not compressed. Use UntarGz, UntarBz2, or UntarZ for the corresponding compressed tarball formats.UntarBz2
# $success is true or false
my $success = $tar->UntarBz2($tarPath);
Decompresses and extracts the .tar.bz2 archive at $tarPath into UntarFromDir. This format is also commonly named .tbz, .tbz2, or .tb2.
Returns 1 on success and 0 on failure. The same extraction filters, path controls, listing options, and output settings used by Untar also apply.
Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
UntarFirstMatchingToBd
# $matchPattern is a string
# $bd is a Chilkat2::BinData
# $success is true or false
my $success = $tar->UntarFirstMatchingToBd($tarPath, $matchPattern, $bd);
Scans the uncompressed TAR archive at $tarPath and copies the contents of the first file whose archive path matches $matchPattern into the BinData object supplied in $bd. Matching is evaluated in archive order.
No archive entry is written to the local filesystem. Returns 1 when a matching file is successfully extracted to $bd and 0 otherwise.
Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
UntarGz
# $success is true or false
my $success = $tar->UntarGz($tarPath);
Decompresses and extracts the .tar.gz archive at $tarPath into UntarFromDir. The .tgz extension is a common short form for the same gzip-compressed TAR structure.
Returns 1 on success and 0 on failure. The same extraction filters, path controls, listing options, and output settings used by Untar also apply.
Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
UntarZ
# $success is true or false
my $success = $tar->UntarZ($tarPath);
Decompresses and extracts the .tar.Z archive at $tarPath into UntarFromDir. The .Z suffix denotes the historical UNIX compress format; .taz is a common alternate extension.
Returns 1 on success and 0 on failure. The same extraction filters, path controls, listing options, and output settings used by Untar also apply.
Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
VerifyTar
# $flag is true or false
my $flag = $tar->VerifyTar($tarPath);
Opens the uncompressed TAR archive at $tarPath and scans its headers through the end of the archive. Returns 1 when the archive structure is accepted and no TAR-format errors are found; otherwise returns 0.
Never dies: false is an answer, not a failure.
topWriteTar
# $success is true or false
my $success = $tar->WriteTar($tarPath);
Creates an uncompressed TAR archive at $tarPath from the files and directory trees previously added with AddFile, AddFile2, AddDirRoot, and AddDirRoot2. Archive paths, permissions, ownership metadata, filters, and header format are controlled by the corresponding properties.
Returns 1 on success and 0 on failure.
Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
WriteTarBz2
# $success is true or false
my $success = $tar->WriteTarBz2($bz2Path);
Creates a bzip2-compressed TAR archive at $bz2Path from the files and directory trees previously added to this object. Common filename extensions include .tar.bz2, .tbz, .tbz2, and .tb2.
Returns 1 on success and 0 on failure.
Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
WriteTarGz
# $success is true or false
my $success = $tar->WriteTarGz($gzPath);
Creates a gzip-compressed TAR archive at $gzPath from the files and directory trees previously added to this object. The usual extensions are .tar.gz and .tgz.
Returns 1 on success and 0 on failure.
Returns true on success, false on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.
Events
All Chilkat methods are synchronous: the call returns when the work is done. During a long-running call, Chilkat2::Tar reports progress to handlers installed with on, which takes Event => CODE pairs (closures, so a handler can use the variables around it):
$tar->on(
PercentDone => sub { my ($pctDone) = @_; print "$pctDone%\n"; return 0 }, # a true return aborts
ProgressInfo => sub { my ($name, $value) = @_; print "$name: $value\n" },
);
$tar->HeartbeatMs(250); # the AbortCheck handler is called 4 times per secondInstalls the handlers given, replacing those installed before for the same events; undef instead of a CODE reference removes one, and $tar->on() with no arguments returns the installed handlers as a list of pairs. The event names are checked: a misspelled one croaks, and nothing is installed.
The AbortCheck handler is called at the interval set by the HeartbeatMs property (0, the default, disables it); PercentDone is called when an operation's completion percentage is known; ProgressInfo delivers named progress values. A true return from the AbortCheck or PercentDone handler aborts the running method, which then fails in the usual way (false or undef, or a Chilkat2::Error under RaiseError).
Handlers run during the method call, on the thread that called it. Inside a handler, other objects may be used, but calling a method of the same object (or its on) croaks. A die in a handler aborts the running method and is re-thrown from the method call; the object remains usable. A handler that uses $tar itself makes a reference cycle: weaken the captured copy (Scalar::Util) or remove the handler when done.
AbortCheck
$tar->on(AbortCheck => sub { ... });
Enables a method call to be aborted by triggering the AbortCheck event at intervals defined by the HeartbeatMs property. If HeartbeatMs is set to its default value of 0, no events will occur. For instance, set HeartbeatMs to 200 to trigger 5 AbortCheck events per second.
Example
my $deadline = time() + 30; # give up after 30 seconds
$tar->HeartbeatMs(250); # call the handler 4 times per second
$tar->on(AbortCheck => sub { return time() > $deadline });PercentDone
$tar->on(PercentDone => sub { ... });
This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The pctDone argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have pctDone equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).
The PercentDone callback also acts as an AbortCheck event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.
To abort the operation, set the abort output argument to 1. This will cause the method to terminate and return a failure status or corresponding failure value.
Example
$tar->on(PercentDone => sub {
my ($pctDone) = @_; # 0 to 100
print "Percent done: $pctDone\n";
return 0; # return a true value to abort the method in progress
});ProgressInfo
$tar->on(ProgressInfo => sub { ... });
This event callback provides tag name/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.
Note: Some Chilkat methods don't fire any ProgressInfo events.
Example
$tar->on(ProgressInfo => sub {
my ($name, $value) = @_;
print "$name: $value\n";
});