use Win32::OLE;
use Win32::SAM;
#use Win32::Slingshot;
$| = 1;
my $URL = "http://www.google.com/";
my $seconds;
$Win32::OLE::Warn = 3;
StartIE();
$seconds = Navigate($URL);
print "Google Page took $seconds seconds to load\n";
SetEditBox("q","Presidents");
$seconds = ClickFormButton("btnG");
print "Query Page took $seconds seconds to load\n";
Going through the code line by line...
$Win32::OLE::Warn = 3;
This line is used to tell the perl interpreter how to handle Win32::OLE errors.
If you open up the c:\perl\site\lib\win32\OLE.pm, you will see some documentation for this line of code:
Editor's notes: Carp is used to display/log what went wrong with the code. croak - means to exit the program.
=item Warn
This variable determines the behavior of the Win32::OLE module when
an error happens. Valid values are:
0 Ignore error, return undef
1 Carp::carp if $^W is set (-w option)
2 always Carp::carp
3 Carp::croak
The error number and message (without Carp line/module info) are
available through the C<Win32::OLE->LastError> class method.
Alternatively the Warn option can be set to a CODE reference. E.g.
Win32::OLE->Option(Warn => 3);
is equivalent to
Win32::OLE->Option(Warn => \&Carp::croak);
This can even be used to emulate the VisualBasic C<On Error Goto
Label> construct:
Win32::OLE->Option(Warn => sub {goto CheckError});
# ... your normal OLE code here ...
CheckError:
# ... your error handling code here ...