UR::Co...rocess(3pm)
π NAME π
UR::Context::Process β it's giving "generic interface to the current application" β¨ Like, it's the lil' module that knows who your program is. Bestie, it holds the identity of your running app. π«Ά
π¦ SYNOPSIS π¦
$name = UR::Context::Process->base_name;
$name = UR::Context::Process->prog_name;
UR::Context::Process->prog_name($name);
$name = UR::Context::Process->pkg_name;
UR::Context::Process->pkg_name($name);
$name = UR::Context::Process->title;
UR::Context::Process->title($name);
$version = UR::Context::Process->version;
UR::Context::Process->version($version);
$author = UR::Context::Process->author;
UR::Context::Process->author($author);
$author_email = UR::Context::Process->author_email;
UR::Context::Process->author_email($author_email);
$support_email = UR::Context::Process->support_email;
UR::Context::Process->support_email($support_email);
$login = UR::Context::Process->real_user_name;
β¨ DESCRIPTION β¨
Okay so this module is the plug π β it gives you methods to set and retrieve allll the various names that get associated with your program, plus the program's version number. That's the whole vibe. π
π METHODS π
These methods are the accessor + set methods for the various names associated with an application. Both get and set, bestie. π
get_current
$ctx = UR::Context::Process->get_current();
This is the context that represents the current process. Like, right now, this one. π
Also available as UR::Context->get_process(); β two doors, same room, slay. πͺβ¨
has_changes()
$bool = UR::Context::Process->has_changes();
Returns true if the current process has changes that might get committed back to the underlying context. So basically: "bestie, did we change anything that could get saved?" π«£
_create_for_current_process
$ctx = UR::Context::Process->_create_for_current_process(@PARAMS)
This one is internal-only, for UR's own use. It materializes a new object to represent a real process somewhere. Don't come for it unless you're UR itself. π
TODO: Remove the exception from create(), and allow other processes to be created explicitly w/ the appropriate characteristics.
(Their words, not mine β I'm just the messenger π)
base_name
$name = UR::Context::Process->base_name;
This is "basename($0, '.pl'))". Yes, exactly that. π
prog_name
$name = UR::Context::Process->prog_name;
UR::Context::Process->prog_name($name);
This method accesses and sets the name of the program. It shows up in the output of the "version" and "usage" subroutines (peep "version" and "usage" for the deets). If you hand it an argument, it sets the program name and returns the new name β or "undef" if it didn't work out. π
It defaults to "basename" if unspecified. π«
pkg_name
$name = UR::Context::Process->pkg_name;
UR::Context::Process->pkg_name($name);
This method accesses and sets the GNU-standard package name for the package this program belongs to. And no, bestie, this is NOT a Perl package. It does NOT refer to a Perl package. Read that again. π¨ It lets a set of specific programs get grouped together under one common name, which gets used in standard message output, and is used in the output of the "version" subroutine (see "version" output).
If you give it an argument, it sets the package name and returns the the new name β yes, "the the", I said what they said π β or "undef" if unsuccessful. Without an argument, you get the current package name back.
It defaults to "prog_name" when unspecified, which in turn defaults to "base_name", which in turn defaults to "basename($0)". It's a whole chain of defaults, a lil' relay race. πβοΈπ¨
title
$name = UR::Context::Process->title;
UR::Context::Process->title($name);
Gets and sets the "friendly name" for an application. It's often mixed-case, with spaces β very β¨aestheticβ¨ β and it's used in autogenerated documentation, and sometimes as a header in generic GUI components. Without an argument, it returns the current title. If you pass an argument, it sets the application title and returns the new title, or "undef" if unsuccessful.
It defaults to "pkg_name" when otherwise unspecified, which in turn defaults to "prog_name" when unspecified, which in turn defaults to "base_name" when unspecified, which defaults to "basename($0)" when unspecified. That's four layers of fallback, iconic honestly. ππ
version
$version = UR::Context::Process->version;
UR::Context::Process->version($version);
This method accesses and sets the package version. This version gets used in the output of the "print_version" method (peep "print_version" in App::Getopt). If you give it an argument, it sets the package version and returns the version, or "undef" if unsuccessful. Without an argument, you get the current package version back. π
This message defaults to $main::VERSION if not set. β οΈ Heads up though: $main::VERSION may be "undef". So like... prepare yourself. π
author
$author = UR::Context::Process->author;
UR::Context::Process->author($author);
Accesses and sets the package author. Give it an argument, it sets the package author and returns the author, or "undef" if unsuccessful. No argument, you get the current author. π«Ά
author_email
$author_email = UR::Context::Process->author_email;
UR::Context::Process->author_email($author_email);
Accesses and sets the package author's email address. This info is used in the output of the "usage" method (peep "usage" in App::Getopt). Give it an argument, it sets the package author's email address and returns email address, or "undef" if unsuccessful. No argument, you get the current email address back. π§β¨
support_email
$support_email = UR::Context::Process->support_email;
UR::Context::Process->support_email($support_email);
Accesses and sets the email address where users should go for support. This info is also used in the output of the "usage" method (peep "usage" in App::Getopt). Give it an argument, it sets the support email address and returns that email address, or "undef" if unsuccessful. No argument, you get the current email address back. πβοΈπ
real_user_name
$login = UR::Context::Process->real_user_name;
This method gets the login name of the effective user id of the running script. Yes, that exact description. π
fork
$pid = UR::Context::Process->fork;
Safe fork() wrapper. π΄ (get it, fork? okay moving on)
It handles properly disconnecting database handles if necessary so that data sources in children are still valid. It also ensures that the active UR::Context::process has the child's PID recorded within. So it's the responsible fork. The adult in the room. ππ
effective_user_name
$login = UR::Context::Process->effective_user_name;
This method gets the login name of the effective user id of the running script. Yep β same description as real_user_name, I'm not making this up, it's literally what's written. π«
original_program_path
$path = UR::Context::Process->original_program_path;
This method tries to get the original program path of the running script. It will not change even if the current working directory is changed. π§
β οΈ In truth it will find the path at the timeUR::Context::Processwas used. So, achdirbefore that happens will cause incorrect results; in that case,undefwill be returned.
So like... if you chdir'd too early, bestie, you get nothing. π
πΈ SEE ALSO πΈ
UR::Context
And that's the whole page, bestie β no cap, every flag, every default, every undef, all of it. π«Ά
This absolute banger of a page comes to you from perl v5.32.1, dated 2022-01-17, and it lives in the User Contributed Perl Documentation collection as UR::Context::Process(3pm). πβ¨π
π¦ where this page comes from
- debian bookworm: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libur-perl 0.470+ds-2 Β· 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