UR::Util(3pm)
π¦ okay bestie, welcome to UR::Util π¦
so this page is literally just a lil grab-bag of utility subs and methods, and ngl the doc layout here is chaotic in a cute way β the functions show up first, then NAME and DESCRIPTION. we're keeping that energy, don't worry. π
β¨ the functions β¨
π path_relative_to π
$rel_path = UR::Util::path_relative_to($base, $target);
gives you back the pathname to $target relative to $base. the tea β:
- if
$baseand$targetare the same, you get'.'. periodt. - if
$targetis a subdirectory of$base, you get the part of$targetthat's unique compared to$base. - if
$targetis not a subdirectory of$base, you get a relative pathname starting with$base.
π generate_readwrite_methods π
UR::Util->generate_readwrite_methods
(
some_scalar_property => 1,
some_array_property => []
);
this one generates accessor/set methods named after the keys of its hash argument. which kind of function you get depends on the default value you pass as the hash key value:
- hash key is a scalar β a scalar method gets generated
- hash key is a reference to an array β an array method gets generated
heads up: this method does not overwrite class methods that already exist. it's polite like that. π
πΈ generate_readwrite_methods_override πΈ
UR::Util->generate_readwrite_methods_override
(
some_scalar_property => 1,
some_array_property => []
);
same as generate_readwrite_function except that we force the functions into the namespace even if the function is already defined. it's giving main character energy, no chill, no waiting for permission. π
π§ generate_readonly_methods π§
UR::Util->generate_readonly_methods
(
some_scalar_property => 1,
some_array_property => []
);
this one generates accessor methods named after the keys of its hash argument. and again, the type of function generated depends on the default value provided as the hash key value:
- hash key is a scalar β a scalar method gets generated
- hash key is a reference to an array β an array method gets generated
same rule as before: this method does not overwrite class methods that already exist. π
π object π
my $o = UR::Util::object($something);
return the object form of the supplied argument. the vibe check:
- regular objects β returns the argument unchanged, no notes, iconic
- singleton class names β returns the instance of the Singleton
- other class names β throws an exception. it said what it said. π
π₯ mapreduce_grep π₯
my @matches = UR::Util->map_reduce_grep { shift->some_test } @candidates;
works similar to the Perl grep builtin, but in a possibly-parallel fashion. so here's the deal:
if the environment variable UR_NR_CPU is set to a number greater than one, it will fork off child processes to perform the test on slices of the input list, collect the results, and return the matching items as a list. multitasking queen fr fr. β¨
the test function is called with a single argument β an item from the list to be tested β and it should return a true or false value.
π NAME π
UR::Util β Collection of utility subroutines and methods
π DESCRIPTION π
This package contains subroutines and methods used by other parts of the infrastructure. These subs are not likely to be useful to outside code.
so basically: it's internal plumbing, bestie. if you're not part of the infrastructure, this is lowkey not for you, and that's fine. π«Ά
okay that's the whole page!! this lil gem ships with perl v5.32.1, dated 2022-01-17, and it lives in the User Contributed Perl Documentation. stay slay, go call some subs. π β¨ππ¦
π¦ 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