BIND::...Parser(3pm)

πŸ“¦
version 0.01 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

BIND::Config::Parser β€” bestie, it parses your BIND config file. That's the whole vibe. (And yeah, it lives in the User Contributed Perl Documentation section, 3pm girlies rise 🫢)


✨ SYNOPSIS ✨

Okay so first you gotta actually bring it into the chat:

use BIND::Config::Parser;

# Create the parser
my $parser = new BIND::Config::Parser;

my $indent = 0;

# Set up callback handlers
$parser->set_open_block_handler( sub {
        print "\t" x $indent, join( " ", @_ ), " {\n";
        $indent++;
} );
$parser->set_close_block_handler( sub {
        $indent--;
        print "\t" x $indent, "};\n";
} );
$parser->set_statement_handler( sub {
        print "\t" x $indent, join( " ", @_ ), ";\n";
} );

# Parse the file
$parser->parse_file( "named.conf" );

That's it, that's the whole little love story πŸ’… You build a parser, you hand it three lil callback subs, you point it at a file, it goes brrr.


πŸ¦‹ DESCRIPTION πŸ¦‹

So BIND::Config::Parser is a lightweight parser for the config-file syntax of BIND v8 and v9, and it does it using a Parse::RecDescent grammar. Slay.

It's kind of in the same lane as BIND::Conf_Parser β€” same energy, different girl. But here's the tea: this one has no knowledge of the directives. Which honestly? Iconic. It means nobody has to keep updating it every time a new directive drops, because it just knows how to carve a BIND config file up into logical chunks. No thoughts, just vibes and grammar rules. ✨


πŸ‘‘ CONSTRUCTOR πŸ‘‘

new( );

Creates a brand new BIND::Config::Parser object. A little baby parser. Your main character. 🌸


🌈 METHODS 🌈

  • set_open_block_handler( CODE_REF ); β€” sets the code that gets called whenever a configuration block gets opened. You'll get at least one argument, and that's the name of the block β€” think options or zone, etc. β€” plus any extra items, up to but not including the opening curly brace. πŸŽ€
  • set_close_block_handler( CODE_REF ); β€” sets the code that gets called whenever a configuration block gets closed. No arguments get passed, it's just vibes. πŸ’œ
  • set_statement_handler( CODE_REF ); β€” sets the code that gets called on a single-line configuration element. You'll get at least one argument, and that's the name of that element, plus any additional items, up to but not including the ending semi-colon. πŸ“
  • parse_file( FILENAME ); β€” parses FILENAME, and triggers all those handlers you set up above on the relevant sections. The moment of truth. ✨

πŸ™ˆ TODO πŸ™ˆ

Probably the odd one or two things. I'm fairly sure the grammar is correct. (ngl, that's the whole TODO. She's confident. πŸ’€)


Copyright (c) 2005 Matt Dainty.

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


🌸 AUTHORS 🌸

Matt Dainty <matt@bodgit-n-scarper.com>.


⭐ SEE ALSO ⭐

  • perl
  • Parse::RecDescent
  • BIND::Conf_Parser

And that's the page, bestie!! This was perl v5.32.0, dated 2021-01-07, straight out of the BIND::...Parser(3pm) page in User Contributed Perl Documentation. Go parse something gorgeous. Periodt. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from