#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    1
    Rep Power
    0

    Open a HTML page from inside perl code


    Hello to all,

    I'm a beginner in Perl programming.
    I'm trying from inside a .pl file (perl file), to open an html pop-up page saying a thing like "Hello World!". Like the pop-up that some times appear in internet pages.

    Can someone help me in this.

    Best Regards
  2. #2
  3. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,221
    Rep Power
    1809
    Presumably you mean in a web server script, that if someone goes to your page the perl script will create a popup window on the user's browser.

    Popup windows are caused by javascript, so that has to be enabled on the user's browser, and the perl script will have to include a javascript function within the returned HTML to cause a popup to occur. There is an example of this within this CPAN module:

    CGI::Application::Plugin::DevPopup

    If you look at the _devpopup_output subroutine, you'll see the javascript component being created.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    25
    Rep Power
    0
    You can also try the CGI module that comes with your perl like thus:

    Code:
    #!/usr/bin/perl -w
    use strict;
    use CGI qw(:standard);
    
     my $html = CGI->new();
    
       print $html->start_html(-title=>'home Page',
                               -script => {-type => 'JAVASCRIPT',
    			               -src => './pop_up.js',
    			              },
                               ),
    
             $html->end_html;
    The javascript script use is named 'pop_up.js', saved in the same location with your perl script.

    Code:
      alert("Hello, world");
    NOTE:
    Though CGI module is old, and there was a discussion to remove it totally from perl default installed modules. I can tell if that has been done. But Perl version 5.16.1 still has it.

    Do perldoc CGI from your Command Line Interface (CLI) to read CGI documentation.

IMN logo majestic logo threadwatch logo seochat tools logo