Error Handling

Generally speaking, when Perl encounters an error, it sets the error variables ($!) to both the error number and the textual error message. This enables the script to determine the nature of a Perl-generated error. The $! variable usually reports system errors. The $^E variable reports Win32 errors. However, most modules and extensions generally do not touch this variable.

Instead, they use their own way of error reporting, which makes it difficult for a coder to discover error information because the technique differs from extension to extension.

The Win32 extension defines two very important error functions: the GetLastError() and FormatMessage().

GetLastError() Function

The Win32::GetLastError() function returns an error code ...

Get Win32 Perl Programming: The Standard Extensions, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.