GO::Utils(3pm)

πŸ“¦
version 0.15 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– GO::Utils(3pm) πŸ’–

okay bestie, welcome to GO::Utils β€” the lil grab-bag of utility functions for GO modules ✨ it ships as part of the User Contributed Perl Documentation, and honestly? it's giving "toolbox that just works." no cap.


🌸 NAME 🌸

GO::Utils β€” utilities for GO modules πŸ§°πŸ’…


✨ DESCRIPTION ✨

it's a collection of helper subs, that's the vibe. let's go through them one by one, bestie 🫢

πŸŽ€ rearrange()

  • Usage β€” n/a
  • Function β€” rearranges named parameters into the order you requested πŸ”€
  • Returns β€” @params, an array of parameters in the requested order
  • Argument β€” $order: a reference to an array that describes the desired order of the named parameters. And @param: an array of parameters β€” either as a plain list (in which case the function simply returns the list, no drama), or as an associative array (in which case the function sorts the values according to @{$order} and hands you back that new array πŸ’–)
  • Exceptions β€” carps if a non-recognised parameter gets sent in 😭

πŸ¦‹ get_param()

  • Usage β€” get_param('name',(-att1=>'ben',-name=>'the_name'))
  • Function β€” fetches a named parameter πŸ”
  • Returns β€” the value of the requested parameter
  • Argument β€” $name: the name of the the parameter desired. And @param: an array of parameters, as an associative array
  • Exceptions β€” carps if a non-recognised parameter gets sent in 😭

this one is based on rearrange(), which originally came from CGI.pm by Lincoln Stein and BioPerl by Richard Resnick πŸ‘‘ see rearrange() for the details, iykyk.

🌈 remove_duplicates

removes duplicate items from an array, bestie β€” decluttering but for data 🧹✨

  • usage β€” remove_duplicates(\@arr)

heads up: it affects the array passed in, and returns the modified array. so it's not a copy situation, it's an in-place glow-up πŸ’…

πŸ’œ merge_hashes

joins two hashes together πŸ«‚

  • usage β€” merge_hashes(\%h1, \%h2);

%h1 will now contain the key/val pairs of %h2 as well. and if there are key conflicts? %h2 values take precedence. periodt πŸ‘‘

πŸ“ get_method_ref

returns a pointer to a particular object's method 🎯 like:

my $length_f = get_method_ref($seq, 'length');
$len = &$length_f();

main character energy fr fr.

⭐ pset2hash

  • Usage β€” my $h = pset2hash([{name=>"id", value=>"56"}, {name=>"name", value=>"jim"}]);
  • Returns β€” hashref
  • Args β€” arrayref of name/value keyed hashrefs

🌸 spell_greek

takes a word as a parameter and spells out any greek symbols encoded within it πŸ›οΈβœ¨ (eg s/&agr;/alpha/g) β€” literal sorcery, we love to see it.

πŸ”₯ check_obj_graph

  • Usage β€” (nothing listed, bestie)
  • Returns β€” true if a cycle is detected πŸ”„
  • Args β€” any object
lowkey important: this is your cycle detector. if it comes back true, you've got a loop situation on your hands πŸ’€

and that's the whole page!! πŸ’–πŸ§š no cap, you're now fully caught up.

perl v5.36.0 Β· 2023-12-18 Β· mwah, go slay πŸ’…πŸ‘‘πŸ«Ά

πŸ“¦ where this page comes from