Hostfile::Manager - Manage a hostfile by composing multiple fragments into a whole.
Contents
Accessors
Strpath_prefix([Str$prefix])
Defines the prefix that will be searched for hostfile fragments. Defaults to '/etc/hostfiles/'.
Strhostfile_path([Str$path])
Defines the path to the hostfile to manage. Defaults to '/etc/hosts'.
Strhostfile
The contents of the hostfile under management.
HashReffragments
The available hostfile fragments.
Arrayfragment_list
A list of the names of available fragments.
Strget_fragment(Str$fragment_name)
The contents of an individual hostfile fragment.
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.
Methods
Hostfile::Manager->new([\%options])
Create a new manager instance. Available options are path_prefix and hostfile_path, listed in the
ACCESSORS section.
Boolwrite_hostfile
Write the contents of the hostfile to disk.
Boolfragment_enabled(Str$fragment_name)
Test whether a named fragment is enabled in the hostfile under management.
enable_fragment(Str$fragment_name)
Enable a named fragment. If the fragment is currently enabled, it will be disabled first, removing
any modifications that may have been made out-of-band.
disable_fragment(Str$fragment_name)
Disable a named fragment.
toggle_fragment(Str$fragment_name)
Enable a fragment if it is disabled, disable it otherwise.
Strfragment_status_flag(Str$fragment_name)
Returns a string indicating the current status of a named fragment.
"+"
The named fragment is enabled.
"*"
The named fragment is enabled and has been modified in the sourced hostfile.
""
The named fragment is not enabled.
Name
Hostfile::Manager - Manage a hostfile by composing multiple fragments into a whole.
Synopsis
use Hostfile::Manager;
$manager = Hostfile::Manager->new;
$manager->enable_fragment($fragment_name);
$manager->write_hostfile;
