Hi all,

I am pretty new to this PERL programming.

I have heard that anything could be done with PERL's magic...
So out of my own interest, I have started learning perl language, to ease my project works(sort of Automation stuffs).
I have PERL V5.10.1 installed in my PC,and am executing my perl scripts in windows environment only.(I find there are some differences in the commands used in windows and in UNIX environment)

As am new to this, am not much aware of all the commands used in perl for different applications.It will very helpful,if anyone could give me a solution for my queries!!!

"I wanted to open a web-page using Perl scripts,say for example, by running my script I should open my web-browser(google page),What packages or modules I need to install, What specific commands will help me out in getting my google page displayed?"

Is this possible via PERL?

Are you sure this is what you want to do? If so, you can control IE through perl... Remember though it is on the CLIENT, not the server.

use Win32::OLE qw( EVENTS in with valof );
use Win32::OLE::Variant;

Win32::OLE->Option( Warn => 0 );

$HomePage = "http://www.google.com/";

$IE = Win32::OLE->GetActiveObject( 'InternetExplorer.Application' );
if( ! defined $IE )
{
    print "Can not find open object. Creating one...\n";
    $IE = Win32::OLE->new( 'InternetExplorer.Application', "Quit" )
             or die "Unable to create a IE Object\n";
}

Win32::OLE->WithEvents( $IE, \&cleanExit, 'DWebBrowserEvents2' );

$IE->{Visible} = 1;
$IE->{RegisterAsDropTarget} = 1;
$IE->{RegisterAsBrowser} = 1;


$IE->Navigate( $HomePage );

# Let IE load the page
while( $IE->{Busy} )
{
    while ($IE->SpinMessageLoop()) { select undef,undef,undef,0.25; }
}
$Doc = $IE->{Document};


sub cleanExit {
    my( $obj, $event, @args ) = @_;
    
    if ($event eq "OnQuit") {
        print "Terminating\n";
        undef $obj;
        exit(1);
    }
}

Are you sure this is what you want to do? If so, you can control IE through perl... Remember though it is on the CLIENT, not the server.

use Win32::OLE qw( EVENTS in with valof );
use Win32::OLE::Variant;

Win32::OLE->Option( Warn => 0 );

$HomePage = "http://www.google.com/";

$IE = Win32::OLE->GetActiveObject( 'InternetExplorer.Application' );
if( ! defined $IE )
{
    print "Can not find open object. Creating one...\n";
    $IE = Win32::OLE->new( 'InternetExplorer.Application', "Quit" )
             or die "Unable to create a IE Object\n";
}

Win32::OLE->WithEvents( $IE, \&cleanExit, 'DWebBrowserEvents2' );

$IE->{Visible} = 1;
$IE->{RegisterAsDropTarget} = 1;
$IE->{RegisterAsBrowser} = 1;


$IE->Navigate( $HomePage );

# Let IE load the page
while( $IE->{Busy} )
{
    while ($IE->SpinMessageLoop()) { select undef,undef,undef,0.25; }
}
$Doc = $IE->{Document};


sub cleanExit {
    my( $obj, $event, @args ) = @_;
    
    if ($event eq "OnQuit") {
        print "Terminating\n";
        undef $obj;
        exit(1);
    }
}

..........................................................................
Hi Mitchem,
Thanks for the quick reply..
I tried your program in my system.Before which I downloaded WIN32::OLE module from CPAN and pasted in C:\PERL\Site\lib\... then when I executed the script, the following error message is shown in the command prompt:
Global symbol "$HomePage" requires explicit package name at D:\perlpgm\google.pl
D:\perlpgm is where I have all my sample programs, google.pl is my script name.
Please tell me how to proceed further!!!

Did you run the code as written or did you add something to it (such as use strict)? The code I wrote will not pass the strict test because I don't declare the variables. If you use strict you have to declare the variables with "my".

Did you run the code as written or did you add something to it (such as use strict)? The code I wrote will not pass the strict test because I don't declare the variables. If you use strict you have to declare the variables with "my".

.............................
Ya ...I used "use strict and use warnings" in the first two lines.
Even without using them....I get message like:"cannot find open object"
then a webpage opens and get closed with no time.....
I couldn't stay at the webpage....need to work on it....What should be done ?
Need any more packages?

Yeah it gets closed in no time because once the perl script is done the connection to IE is done.

If you're interested in learning Perl for Web apps, the easiest way to do it is to install Wampserver or Apache and Activestate Perl on your machine - Wampserver is an all-in-one with Apache, Perl, PHP and MySQL packaged with it. There are some other servers out there but I personally like Apache.

Once you have the server installed and configured you just point your browser to 'localhost/cgi-bin/???.pl and you're ready to go. (And with a server you also get error logs that tell you what you did wrong {VBG}

Comments
Great advice!

If you're interested in learning Perl for Web apps, the easiest way to do it is to install Wampserver or Apache and Activestate Perl on your machine - Wampserver is an all-in-one with Apache, Perl, PHP and MySQL packaged with it. There are some other servers out there but I personally like Apache.

you cant get a better advice these days like that for free ;)

This article has been dead for over six months. Start a new discussion instead.