Browser::Open(3pm)
π Browser::Open β the perl module that yeets a URL into your browser π
okay bestie, listen β this is Browser::Open, a lil module from the User Contributed Perl Documentation corner of the perl universe, and it does exactly one iconic thing: it opens a URL in the user's browser. That's it. That's the whole vibe. π¦
β¨ VERSION β¨
version 0.03 β she's an elder but she still slays π
π SYNOPSIS π
Like, here's the whole entire fantasy:
use Browser::Open qw( open_browser );
### Try commands specific to the current Operating System
my $ok = open_browser($url);
# ! defined($ok): no recognized command found
# $ok == 0: command found and executed
# $ok != 0: command found, error while executing
### Try all known commands
my $ok = open_browser($url, 1);
no cap, that's literally it. three lines and your URL is out there living its main character life. π
πΈ DESCRIPTION πΈ
So the functions this module optionally exports β and yes, optionally, we'll get to that β let you open URLs in the user's browser. π«Ά
The way it works is lowkey genius: there's a set of known commands, one set per OS-name, and it goes down the list checking for presence, and the first one it finds gets executed. That's the default behavior, bestie. But if you pass the optional parameter, it'll check all the known commands instead. greedy girl behavior, honestly, and I respect it. π
Also important: open_browser uses the system() function to actually execute the command. So if you're the type who needs more control β a control freak, an auteur, a director β you can just grab the command yourself with open_browser_cmd or open_browser_cmd_all and then execute it however you want. your life, your rules. π
β API β
π¨ Vibe check first: all of these functions are NOT exported by default. You have to ask for them explicitly, like asking your friend to pass you your iced coffee. Nothing comes for free here, bestie.
π¦ open_browser
my $ok = open_browser($url, $all);
Finds an appropriate command and executes it with your $url. π«
If $all is false β which is the default, btw β only the commands that match the current OS get tested. If it's true, then all the known commands get tested. Go big or go home. π₯
Now the returns, and pay attention because this is the part people mess up:
- If no command was found at all, it returns
undef. π - If a command is found, it returns the exit code of the execution attempt β
0means success, obviously. And if you want the whole lore on that exit code, go read up onsystem(). π - If you don't give it a
$urlat all? It throws an exception:Missing required parameter $url. periodt. it will not be ignored, it will not be gentle, it will simply throw. π
π§ open_browser_cmd
my $cmd = open_browser_cmd();
Returns the best command found to open a URL on your system. the bestie. the chosen one. the one that gets the aux cord. π
And if no command was found? undef. π
π open_browser_cmd_all
my $cmd = open_browser_cmd_all();
Returns the first command found to open a URL. note: first, not best. it's not picking favorites, it's just picking whoever showed up first to the party. π
And if no command was found β you already know β undef. π
π AUTHOR π
Pedro Melo, "<melo at cpan.org>" β absolute icon, wrote this whole thing, we stan. π«Ά
π COPYRIGHT & LICENSE π
Copyright 2009 Pedro Melo.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay, open source, we love to see it β¨
and that's the whole page, bestie!! this was documented with perl v5.32.0, dated 2021-01-03, and yes the header at the top and footer at the bottom of the original both said Browser::Open(3pm) because that's just how manpages do. now go open a browser. you deserve it. ππΈπ¦ππ
π«Ά
π¦ where this page comes from
- debian bookworm: libbrowser-open-perl 0.04-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libbrowser-open-perl 0.04-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libbrowser-open-perl 0.04-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libbrowser-open-perl 0.04-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms