use strict;
use warnings;
use Win32;
use Win32::GUI();
use Win32::API;
Win32::API->Import('kernel32','BOOL SetConsoleIcon(HWND icon)');
eval{SetConsoleIcon( Win32::GUI::Icon->new('box1.ico')->{-handle});}; #eval 2 counter the die from undef return from "new" with "->"
print 0+$^E; print " ---\n".'$^E = '; #separated \n just in case
print $^E; print " ---\n".'$! = ';
print $!; print " ---\n".'$@ = ';
print $@; print " ---\n".'FormatMessage = ';
print Win32::FormatMessage(Win32::GetLastError());
sleep 50;
exit;
####
0 ---
$^E = ---
$! = Bad file descriptor ---
$@ = ---
FormatMessage = The operation completed successfully.
####
0 ---
$^E = ---
$! = Bad file descriptor ---
$@ = Can't use an undefined value as a HASH reference at E:\perl experiments\change icon exp 2.pl line 8.
---
FormatMessage = The operation completed successfully.
####
2
The system cannot find the file specified.