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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



PapaGeek
User

Apr 19, 2014, 5:46 AM

Post #1 of 5 (9373 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:


Code
$html = $window->Scrolled ('HyperText', 
-scrollbars => 'ose',
-wrap => 'word',
)->pack();
. . .
$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.


FishMonger
Veteran / Moderator

Apr 19, 2014, 6:34 AM

Post #2 of 5 (9372 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.
http://search.cpan.org/~bzajac/Proc-Background-1.10/lib/Proc/Background.pm

Or, Win32::Process
http://search.cpan.org/~jdb/Win32-Process-0.16/Process.pm


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


BillKSmith
Veteran

Apr 19, 2014, 7:45 AM

Post #3 of 5 (9367 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:

Code
    system  "$BROWSER $fname";


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


FishMonger
Veteran / Moderator

Apr 19, 2014, 8:18 AM

Post #4 of 5 (9365 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.


PapaGeek
User

Apr 19, 2014, 10:02 AM

Post #5 of 5 (9360 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:


Code
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