gw1500se has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to write a script that will use a browser to interact with the user (I figure this is the best way to make it platform independent). Unfortunately I cannot even get up to bat. All that happens is that my HTML is written to the command line.

I am guessing that for whatever reason, HTML::Display cannot determine the default browser for the system. I am using Cygwin at the moment.

Here is my "Hello world!" code:
#! /usr/bin/perl -w use strict; use HTML::Display; my $browser=HTML::Display->new(); if (defined($browser)) { my $mypage="<html><body><h1>Hello world!</h1></body></html>"; $browser->display(html=>$mypage); } else { print("Unable to open browser: $@\n"); }
Can someone help me get started? TIA.

Replies are listed 'Best First'.
Re: HTML::Display help needed
by jethro (Monsignor) on Aug 21, 2008 at 00:07 UTC

    What does the following line output? I got this code from the example in the HTLM::Display documentation btw.

    warn "# Displaying HTML using " . ref $browser;

    If that shows that HTML::Display doesn't find a browser (which seems probable), the doc also gives examples how you can specify the browser with environment variables

      Thanks for the reply. It shows:

      # Displaying HTML using HTML::Display::Dump at ...

      I guess that means it did not find a browser. I saw the environment variables but it was not clear what to set them to (a path?). Also, how do I determine the OS so I know what to set the path to?

        I'm always trying to improve my documentation. Currently, it says:

        If HTML::Display already provides a class for the browser you want to use, setting PERL_HTML_DISPLAY_CLASS to the name of the class will make HTML::Display use that class instead of what it detects.

        Maybe you can help me improve the documentation so it becomes clearer what to put in there.

Re: HTML::Display help needed
by Anonymous Monk on Aug 21, 2008 at 05:53 UTC
    I am trying to write a script that will use a browser to interact with the user (I figure this is the best way to make it platform independent)...

    You're barking up the wrong tree. HTML::Display is not a web server. It doesn't speak HTTP or CGI