#
use strict;
use warnings;
use Win32::OLE qw(EVENTS);
my $str = <<EOF;
<rootOfAllEvil>
    <cause>money</cause>
	<needs>more money</needs>
</rootOfAllEvil>
EOF
my $xmlDOC = Win32::OLE->new('MSXML2.DOMDocument.4.0') or die "couldn't create";
# print "ref($subREF)\n";
$xmlDOC->{async} = "True";            # disable/enable asynchronous
my $subREF = \&printState;
# print "ref($subREF)\n";
Win32::OLE->WithEvents($xmlDOC, $subREF);
my $boolean_Load = $xmlDOC->LoadXML($str);
sub printState
{
    my $state = $xmlDOC->{readyState};
    ACTION:
    {
		print "Ready State Event is: ";
        if ($state == 1) {print "Loading\n"; last ACTION;};
        if ($state == 2) {print "Loaded\n"; last ACTION;};
        if ($state == 3) {print "INTERACTIVE\n"; last ACTION;};
        if ($state == 4) {print "COMPLETED\n"; last ACTION; };
    }
    Win32::Sleep(50);
};