O'Reilly logo

Win32 Perl Programming: The Standard Extensions, Second Edition by Dave Roth

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required