in reply to Re^5: HTML::Display help needed
in thread HTML::Display help needed

I saw this:

If there is no specialized class yet, but your browser can be controlled via the command line, then setting PERL_HTML_DISPLAY_COMMAND to the string to navigate to the URL will make HTML::Display use a system() call to the string. A %s in the value will be replaced with the name of the temporary file containing the HTML to display.

I don't understand it. Is it trying to say I should launch the browser from command line, then use PERL_HTML_DISPLAY_COMMAND as a scalar to pass the string? What do I pass to '$browser->display'?

Replies are listed 'Best First'.
Re^7: HTML::Display help needed
by jethro (Monsignor) on Aug 22, 2008 at 02:46 UTC

    Lets say you have a browser /usr/bin/firefox on your machine and you can start firefox simply with an URL as parameter like this:  /usr/bin/firefox http://www.google.com would start firefox with google displayed.

    Then you can set the environment variable PERL_HTML_DISPLAY_COMMAND to '/usr/bin/firefox %s' and otherwise leave your script unchanged.

    That's it. Run your script. It will automatically call firefox and substitute %s with the name of a temporary file it just generated

      Thanks for the reply. That moves the ball ahead a little, although that seems different then what the documentation describes. Anyway, IE will not load and I get an error saying pretty much that. Interestingly, Firefox does indeed load but only brings up the home page not the temp file. Here is the code I have now:
      $ENV{'PERL_HTML_DISPLAY_COMMAND'}='run "C:\Program Files\Mozilla Firef +ox\firefox.exe" %s'; 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"); }

        Strange, it is exactly how I read the documentation. What sentence do you think contradicts my interpretation? It might help Corion improve the documentation

        I tried your code (with my firefox command on linux) and it worked like a charm. Which points to your "run ..." call that might not be right. Have you tried the following on your command shell?

        run "C:\Program Files\Mozilla Firefox\firefox.exe" www.google.com

        Does it work? If not, why should the script work. If yes, try some variations. Delete the "" or put the "" around C:....firefox.exe and %s. Remove the run command (which looks useless to me, but I don't know windows).