Catman...nclude(3pm)

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

πŸ’– NAME πŸ’–

Catmandu::Fix::include β€” bestie, it's the fix that goes "hold up, lemme grab some more fixes from another file real quick" 🫢

It's part of the Catmandu::Fix family, documented in the User Contributed Perl Documentation section (that's the 3pm part of Catman...nclude(3pm), iykyk).


✨ SYNOPSIS ✨

include('/path/to/myfixes.txt')
include('fixes/*.fix')

Literally that simple. Point it at a file, or point it at a glob and watch it eat a whole folder of fixes. πŸ¦‹


πŸ“ NOTES πŸ“

Okay so the path you give it is relative to a Catmandu load path. Not the filesystem, not your cwd, not vibes β€” the load path. Let's break it all the way down:

  1. a catmandu load path is a directory where a catmandu configuration file can be found
  2. as there are multiple load paths, it will loop through all the path, and include the first file it can find
  3. in catmandu, the default_load_path is either
    • 3.1. the directory of the running script
    • 3.2. the parent directory of the running script if the directory is 'bin'
Note: that second one is the sneaky one. If your script lives in a bin directory, Catmandu is like "bestie I'm not looking in bin, I'm looking at the parent of bin" πŸ’…

Now the receipts, aka the examples. Every single one, exactly as it comes:

#use default load_path
#called from script "/opt/catmandu-project/fix.pl"
#default_load_path: /opt/catmandu-project
#file must be located at "/opt/catmandu-project/fixes/myfixes.txt"
Catmandu->fixer("include('fixes/myfixes.txt')");

#use default load_path
#called from script "/opt/catmandu-project/bin/fix.pl"
#default_load_path: /opt/catmandu-project (notice the absence of 'bin')
#file must be located at "/opt/catmandu-project/fixes/myfixes.txt"
Catmandu->fixer("include('fixes/myfixes.txt')");

#load fixes, located at /opt/catmandu-project/fixes/myfixes.txt
Catmandu->load("/opt/catmandu-project");
Catmandu->fixer("include('fixes/myfixes.txt')");

#look for 'fixes/myfixes.txt' in /opt/catmandu-project2, and if that fails in /opt/catmandu-project-1
Catmandu->load("/opt/catmandu-project2","/opt/catmandu-project-1");
Catmandu->fixer("include('fixes/myfixes.txt')");

#if "/opt/catmandu-project/fixes/myfixes2.txt" does not exists, the fix will fail
Catmandu->load("/opt/catmandu-project");
Catmandu->fixer("include('fixes/myfixes2.txt)");

See that last one? If the file isn't there, the fix does not gracefully shrug it off. It fails. No cap. 😭


πŸŒ€ The Two Big Gotchas πŸŒ€

circular references are not detected

Fr fr β€” it will not notice. It will not warn you. It will not save you. πŸ™ˆ

if the 'include' is enclosed within an if-statement, the fixes are inserted in the control structure, but only executed if the if-statement evaluates to 'true'.

Read that again, because it's giving subtle-but-important. The fixes get inserted into the control structure regardless β€” they're just not executed unless the condition is true. Two different things, bestie. πŸŽ€

#the fixes in the file 'add_address_fields.txt' are only executed when field 'name' has content,
#but, the fixes are included in the control structure.
if all_match('name','.+')
    include('add_address_fields.txt')
end

πŸ‘€ SEE ALSO πŸ‘€

  • Catmandu::Fix β€” go read the parent, it's iconic πŸ”₯

And that's the whole page, bestie. This one came out of perl v5.40.1, dated 2026-01-24, filed under the Catmandu::Fix::include(3pm) name in the User Contributed Perl Documentation β€” so if you're holding a different version, check your own docs before you come for me πŸ’… Mwah, go include some fixes. ✨🌸

πŸ“¦ where this page comes from