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.
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.
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.
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.
on windows: start on modern unixen (that is to say, those with xdg-utils installed): xdg-open