CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Link to Web Page



Apr 19, 2014, 5:46 AM

Post #1 of 5 (9812 views)
Link to Web Page Can't Post

Is there a way to link to a web page from within a Perl program?

I am familiar with the:

$html = $window->Scrolled ('HyperText', 
-scrollbars => 'ose',
-wrap => 'word',
. . .
$html->loadString ( $reportText );

Command that lets you display a limited html page in a Tk Window.

I want to bring up the default browser and display an html page.

Veteran / Moderator

Apr 19, 2014, 6:34 AM

Post #2 of 5 (9811 views)
Re: [PapaGeek] Link to Web Page [In reply to] Can't Post

You'll want to fork and exec a new process to launch the browser.

Take a look at using Proc::Background.

Or, Win32::Process

(This post was edited by FishMonger on Apr 19, 2014, 6:35 AM)


Apr 19, 2014, 7:45 AM

Post #3 of 5 (9806 views)
Re: [PapaGeek] Link to Web Page [In reply to] Can't Post

One of my most frequently used perl programs does all of its output by creating a temp html file and displaying it with:

    system  "$BROWSER $fname";

Note: The file usually contains several links.
Good Luck,

Veteran / Moderator

Apr 19, 2014, 8:18 AM

Post #4 of 5 (9804 views)
Re: [BillKSmith] Link to Web Page [In reply to] Can't Post

The problem with using a simple system call in this case is that it blocks until the browser is closed, which is not what you want in an event driven Tk app.


Apr 19, 2014, 10:02 AM

Post #5 of 5 (9799 views)
Re: [FishMonger] Link to Web Page [In reply to] Can't Post

I feel totally bad for even asking this question before I did a complete Google search. The answer is very simple! I’m working with Windows 7, not sure if this also works on UNIX, but the answer is:

my $commandline = qq{start "$Filename" "$Filename"};  
system($commandline) == 0 or die qq{Couldn't launch '$commandline': $!/$?};

The page I want to show is on my local disk and I just have to give the path to it.

The page displays as a new tab in my default browser and the program continues to run. I can easily have 3 buttons to create three reports, click on each button one after the other, and my browser will then have 3 tabs, one for each report. The Perl program does not wait for the web page / browser window to be closed before continuing.

Of course after asking such an easy question I should be talking about my "Pearl" program so everyone thinks I'm a total newbie!

The windows “start” function automatically looks up the .htm extension and opens the appropriate program to display it, in this case the default browser.

A quirk in windows requires that the filename/path be entered twice!

(This post was edited by PapaGeek on Apr 19, 2014, 10:09 AM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives