Catman...etValue(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– Catmandu::Fix::SimpleGetValue πŸ’–

okay so bestie, welcome to the Catman...etValue(3pm) page β€” it lives in the User Contributed Perl Documentation section and it is genuinely the blueprint for making your own emit Fixes. slay.


✨ NAME ✨

Catmandu::Fix::SimpleGetValue β€” a helper class for creating emit Fix-es. no cap, that's the whole job description 🫢


🌸 SYNOPSIS 🌸

here's the glow-up moment β€” building a whole Rot13 encrypter:

# Create a Rot13 encrypter

package Catmandu::Fix::rot13;

use Catmandu::Sane;
use Moo;
use Catmandu::Fix::Has;

has path => (fix_arg => 1);

with 'Catmandu::Fix::SimpleGetValue';

sub emit_value {
    my ($self, $var, $fixer) = @_;
    "${var} =~ y/A-Za-z/N-ZA-Mn-za-m/ if is_string(${var});";
}

# Now you can use this Fix in your scripts
rot13(my.deep.nested.path)
rot13(authors.*)

and then you just… use it. in your scripts. like it's nothing. iconic behaviour honestly πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so Catmandu::Fix::SimpleGetValue exists purely to make life easier when you're creating emit Fixes that transform values on a JSON path. that's it. that's the vibe. ✨

any Fix package that implements Catmandu::Fix::SimpleGetValue has to implement a method called emit_value. that method takes:

  • the variable name the Fix operates on
  • an instance of Catmandu::Fix

and it should return a string containing the Perl code that transforms values on a JSON path.

🫢 lowkey important caveat: in an emit Fix you can't inspect the actual value the Fix runs on. $var holds a variable name, not the actual value. the real values only show up at run time. emit Fixes are the mechanism that compiles Perl code into Fix modules, and those modules are what actually do the transformation. so yeah, $var is giving placeholder energy, not value energy. πŸ’€

want more examples? go read the source code of these absolute legends:

  • Catmandu::Fix::append;
  • Catmandu::Fix::replace_all
  • Catmandu::Fix::upcase

🌈 SEE ALSO 🌈

  • Catmandu::Fix

and that's the whole page, bestie πŸŽ€ go forth and write emit Fixes. stay hydrated, keep your $var sussy, and remember β€” this page was brought to you by perl v5.40.1, dated 2026-01-24. mwah πŸ’–πŸ§šπŸŒΈ

πŸ“¦ where this page comes from