in reply to Perl Windows Open a Web Browser

The simplest way is to leave it all to Windows:

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

Update: The start command was missing from the command line. Oops.

Replies are listed 'Best First'.
Re^2: Perl Windows Open a Web Browser
by SteveS832001 (Sexton) on Apr 09, 2007 at 20:21 UTC
    Well I must not understand the code you wrote, but you gave me an idea So I tried this and it works fine

    $url = 'http://127.0.0.1:8000'; system("explorer $url");
      Good idea (I hope). start is a "program" that comes with Windows, and that serves to start up documents in their default program. Or, as in this case, URLs.

      But start is not trouble free, on some instances of Windows, it is not a standalone program, but a built-in in cmd, the command line interpreter. And then, this command will not work. There have been longish discussions in the Chatterbox on how you can use

      cmd /c start $url
      (IIRC) to get arround that limitation, but it appears to me that using explorer.exe to dispatch to the proper default program will work just as well. And be less of a silly hack. At least, here, it opens in MSIE7 and not in an explorer (file browse) window, I'll have to try it at home to see if it'll cooperate with Firefox too.