Mon::Protocol(3pm)

πŸ“¦
version 1.2.0 Β· 5 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ¦‹ NAME

okay so bestie, meet Mon::Protocol β€” it's literally Methods for parsing / dumping a protocol block. that's the whole vibe πŸ’…


✨ SYNOPSIS

use Mon::Protocol;

that's it. that's the whole setup. iconic behavior honestly πŸŽ€


πŸ’– DESCRIPTION

soooo this section of the og page is just… blank 🌸 nothing here. no cap, it's giving mysterious. we move on, the methods are where the party's at πŸ‘‘


🌸 METHODS

new

creates a brand new object for you, fresh out the box ✨ you can hand it a hash and that hash sets your default values. here's an example with literally every variable you're allowed to initialize:

$c = new Mon::Protocol;

dump_data

hands you back your current internal structure as a string dump β€” and that dump is formatted so you can feed it straight into parse_data. round trip, slay πŸ’«

parse_data

parses a command block for you, going from begin_block all the way to end_block, exactly the way dump_data would have generated it. so like… the inverse of dump_data, bestie 🫢

type(new_type)

sets or returns the type of the current command block. for valid type codes, go look at @TYPES πŸ‘€

and here's the tea: in the future it's possible this module will do extra checking based on the type. but for now? nope. it's left to the application to interpret this. so don't come for the module, it's just not that girl yet πŸ’€

get_section_list

returns an array holding all the section names inside the block. all of them. every single one 🌈

get_section(section_name)

returns a hash containing the key/value pairs of that specific section you asked for πŸ“

delete_section(section_name)

completely removes the specified section from the block. gone. poof. no takebacks 😭

add_to_section(section_name, $hash_ref)

adds the key/value pairs in that hash right into the specified section. like so:

$foo->add_to_section("_hostgroup", { "ns1.baz.com" -> "ok" });

delete_from_section(section_name, $key)

deletes that key/value pair from the section. bye bestie πŸ‘‹

$foo->delete_from_section("_hostgroup", "ns1.baz.com");

error

so if any of these functions return an error, and that error is -1, you use this one to grab a more elaborate error message and to reset the internal error state. two jobs, one method, highkey efficient 🧚

fr fr, remember: -1 means something went wrong, and error is how you get the receipts and then wipe the slate clean.

that's the whole page bestie, you ate that πŸ’œ this one's from perl v5.32.0, dated 2021-01-04, and it's the Mon::Protocol(3pm) page β€” iykyk 🌟

πŸ“¦ where this page comes from