Mnet::Opts - Work with Mnet::Opts objects


    # requried to use this module
    use Mnet::Opts;

    # some options can be set as pragmas
    use Mnet::Opts::Set::Debug;

    # options objects can be created
    my $opts = Mnet::Opts({ default => 1 });

    # options can be accessed via hash keys
    my $value = $opts->{default};

    # options can be accessed via method call
    $value = $opts->default;


Mnet::Opts can be used to work with new Mnet::Opts objects, as shown in the example above.

Refer also to Mnet::Opts::Cli module, used for parsing command line options.


Mnet::Opts implements the methods listed below.


    $opts = Mnet::Opts->new(\%opts)

The Mnet::Opts->new class method returns an Mnet::Opts option object.

The input opts hash reference argument is not required. Any An input hash reference of options can be supplied but is not required.

Note that any Mnet::Opts::Set sub-modules that have been used will be set in the output Mnet::Opts object.

option methods

    $value = $opts->$option

Option values may be accessed using autoloaded method calls, for example:

    use Mnet::Opts;
    my $opts = Mnet::Opts({ default => 1 });
    my $value = $opts->default;

Note that the universal 'can' method call does not work for these autoloaded option name methods. Method calls for options that do not exist will return a value of undefined.

It is also ok to directly access the values of hash keys in the options object.