Mathieu Longtin
Mathieu Longtin

Reputation: 16710

How do you open a browser to a URL using ActivePerl on Windows?

In ActivePerl on Windows, how do I open a browser to some URL?

In Python, there is webbrowser.open(url), but I can't seem to find the Perl equivalent.

Upvotes: 3

Views: 3715

Answers (3)

MkV
MkV

Reputation: 3096

on windows: start on modern unixen (that is to say, those with xdg-utils installed): xdg-open

Upvotes: -1

Chris Lutz
Chris Lutz

Reputation: 75429

I know you're using ActivePerl on Windows, but if you want portability then a system() call is probably the wrong way to go. On OS X, you could change 'start' to 'open', but on many other systems you'll have to use another word, or may not have an equivalent command at all. This kind of thing is really OS- and browser-dependent.

Upvotes: 1

Chad Birch
Chad Birch

Reputation: 74588

Not sure if there's a "right" way to do it, but this should work:

my @command = ('start', $url);
system(@command);

"start" is a windows command that will use whatever the associated program is to open the argument. So as long as $url looks like a URL (make sure it starts with http(s)://), it should start up the browser.

Upvotes: 7

Related Questions