Catman...::Util(3pm)

πŸ’– NAME πŸ’–

okay so bestie, this is Catman...::Util β€” manual section 3pm β€” and lowkey its whole thing is being utility functions and generic fixes developed for the Datahub project. that's it, that's the vibe. ✨


🌸 SYNOPSIS 🌸

use Catmandu::Fix::Datahub::Util;

like. just pull it in. that's the whole synopsis. iconic behavior honestly. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

use Catmandu::Fix::Datahub::Util;

okay so first things first, yeah, you use it, same as above, no cap. and then you get these two little helper cuties:

✨ declare_source($fixer, $var, $declared_var)

so picture this: you've got an item $var, and $var is a path β€” like, a string, a path inside a Catmandu fix, mmmkay? what this function does is take the value sitting at that path and assign it to $declared_var, which is a variable you already declared earlier in the fix code. you don't get to just conjure it, bestie, it has to already exist. 🫢

here's the vibe:

my $f_var = $self->fixer->generate_var();
$code .= "my ${f_var};";
$code .= declare_source($self->fixer, 'foo.bar', $f_var);

see how $f_var gets generated, declared, and then handed over? that's the order. don't skip steps. πŸ™ˆ

🌈 walk($fixer, $path, $key, $h)

now this one walks through a $path β€” and heads up, that path comes in as an arrayref β€” until it gets to $key. then it assigns the value of $key to $h. and listen, $h must be declared in the fix code. must. be. declared. no shortcuts, no vibes-based variable creation. 😭

like so:

my $f_var = $self->fixer->generate_var();
$code .= "my ${f_var};";
$code .= walk($self->fixer, ['foo', 'bar'], $f_var);

same energy as before: generate, declare, walk. slay. ⭐


πŸ‘‘ AUTHOR πŸ‘‘

Pieter De Praetere <pieter@packed.be>

shoutout to the author, we love a credit where credit is due. πŸ’œ


Copyright 2017- PACKED vzw


🧚 LICENSE 🧚

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

so basically: go off, remix it, share it, same terms as Perl, periodt. πŸ“


πŸ”₯ SEE ALSO πŸ”₯

  • Catmandu β€” yeah go look at that one too, it's the whole ecosystem bestie

and that's a wrap!! this page was served up by perl v5.36.0, dated 2023-02-03, and honestly? she ate. bye bestie, go write some fixes πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from