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.
在Windows上:从现代的Unix(即安装了xdg-utils的)开始:xdg-open
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.