---
name: "Hostfile::Manager"
section: "3pm"
platform: "linux"
package: "libhostfile-manager-perl"
version: "0.09-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Hostfile::Manager"
---

# Hostfile::Manager(3pm)

Manage a hostfile by composing multiple fragments into a whole.

## 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;
```

## ACCESSORS

- **Str path\_prefix( \[Str $prefix\] )**

  Defines the prefix that will be searched for hostfile fragments.  Defaults to '/etc/hostfiles/'.

- **Str hostfile\_path( \[Str $path\] )**

  Defines the path to the hostfile to manage.  Defaults to '/etc/hosts'.

- **Str hostfile**

  The contents of the hostfile under management.

- **HashRef fragments**

  The available hostfile fragments.

- **Array fragment\_list**

  A list of the names of available fragments.

- **Str get\_fragment( Str $fragment\_name )**

  The contents of an individual hostfile fragment.

## METHODS

- **Hostfile::Manager-\>new( \[\\%options\] )**

  Create a new manager instance.  Available options are **path\_prefix** and **hostfile\_path**, listed in the ACCESSORS section.

- **Bool write\_hostfile**

  Write the contents of the hostfile to disk.

- **Bool fragment\_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.

- **Str fragment\_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.

## 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.

## AUTHOR

Anthony J. Mirabella \<mirabeaj AT gmail DOT com\>
