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

Hello everybody! I have a perl script which creates a html file, something like this: I write blah.pl and the file blah.html is created.I open the html file by clicking on it, but I want it to run automaticaly, without searching in the directory for it and clicking on it. Can you help me? Thank you very much for your time

Replies are listed 'Best First'.
Re: run file
by Corion (Patriarch) on Aug 18, 2003 at 11:01 UTC

    If you are under Windows, there is the simple minded way of simply "starting" the file through the associated program :

    my $htmlfile = "c:\\test.html"; system(qq{start "$htmlfile"});

    If you are not on Windows, or want to keep up some semblance of portability, there is my module HTML::Display, which tries to make displaying HTML in a browser somewhat less platform dependent, but it is not yet distributed stand-alone.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
      I am under solaris and i use perl version 5004.04!I want to run the html file! thank you!
        One doesn't "run html files". HTML files contain data; HTML is not a programming language. If you mean you want to display an HTML file from within your Perl program, the following ought to work:
        system netscape => "file:///home/you/path/to/file.html";

        assuming that netscape is in your PATH.

        Or, if netscape is already running, you do something like:

        system netscape => 'remote', 'openURL(file:///home/you/path/to/fil +e.html,new_window)';

        Abigail

        A reply falls below the community's threshold of quality. You may see it by logging in.
        A reply falls below the community's threshold of quality. You may see it by logging in.
Re: run file
by Abigail-II (Bishop) on Aug 18, 2003 at 11:02 UTC
    You want to run what automatically? The program? Look into cron, or whatever it's called on your OS. Or your browser? Then perhaps you need the system command, assuming your browser can take a URL as argument.

    Abigail