Hostfi...Manager(3pm)
π Hostfile::Manager π
okay bestie so this is Hostfile::Manager (the (3pm) perl manual page, yk, the one you keep opening and closing without reading) and it is literally here to manage a hostfile by composing multiple fragments into a whole. no cap. it's giving "modular hosts file energy" and honestly? obsessed. π
β¨ NAME β¨
Hostfile::Manager β manage a hostfile by composing multiple fragments into a whole. periodt. π
πΈ SYNOPSIS πΈ
use Hostfile::Manager;
$manager = Hostfile::Manager->new;
$manager->enable_fragment($fragment_name);
$manager->write_hostfile;
likeβ¦ three lines and your /etc/hosts situation is handled. main character behavior fr fr. π
π¦ ACCESSORS π¦
these are the lil getter/setter besties. pass a value in, set it. pass nothing, get it. iconic.
Str path_prefix( [Str $prefix] )β defines the prefix that will be searched for hostfile fragments. it defaults to/etc/hostfiles/so like, that's where it's gonna go looking. πStr hostfile_path( [Str $path] )β defines the path to the hostfile to manage. defaults to/etc/hosts. yes, that/etc/hosts. πStr hostfileβ the contents of the hostfile under management. the whole vibe, in a string.HashRef fragmentsβ the available hostfile fragments. a hashref, as the name literally says.Array fragment_listβ a list of the names of available fragments. just the names, not the contents, bestie.Str get_fragment( Str $fragment_name )β the contents of an individual hostfile fragment. hand it a name, it hands you the goods. π«Ά
π METHODS π
Hostfile::Manager->new( [\%options] )β create a new manager instance. the available options arepath_prefixandhostfile_path, both of which are listed up in the ACCESSORS section (go look, i'll wait π).Bool write_hostfileβ write the contents of the hostfile to disk. like, actually commit it. returns a Bool. πΎBool fragment_enabled( Str $fragment_name )β test whether a named fragment is enabled in the hostfile under management. yes/no, that's it.enable_fragment( Str $fragment_name )β enable a named fragment. β οΈ heads up though: if the fragment is currently enabled, it will be disabled first, and that nukes any modifications that may have been made out-of-band. so like, out-of-band edits? gone. bye. πdisable_fragment( Str $fragment_name )β disable a named fragment. simple. clean. slay.toggle_fragment( Str $fragment_name )β enable a fragment if it is disabled, disable it otherwise. the flip-flop. the switch. πStr fragment_status_flag( Str $fragment_name )β returns a string indicating the current status of a named fragment. and the possible strings are:"+"β the named fragment is enabled."*"β the named fragment is enabled and has been modified in the sourced hostfile." "β the named fragment is not enabled. (yes that is literally a single space. a whole entire space as a status. we love a subtle queen. β¨)
π LICENSE π
Copyright (c) 2010-11,2018 Anthony J. Mirabella. All rights reserved. this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so like, go off, but respectfully. π«Ά
π AUTHOR π
Anthony J. Mirabella <mirabeaj AT gmail DOT com>
and that's the whole page bestie!! π¦β¨ this was written against perl v5.36.0 and the page itself is dated 2022-11-19 β tysm for reading, mwah, go fix your hosts file ππ
π¦ where this page comes from
- debian bookworm: libhostfile-manager-perl 0.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhostfile-manager-perl 0.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhostfile-manager-perl 0.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhostfile-manager-perl 0.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhostfile-manager-perl 0.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms