The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::Mechanize::Script::Util - some basic utility functions for scripts

VERSION

version 0.101

EXPORTS

This module doesn't export anything by default, but any of the following on request:

  • opt_required_all

  • opt_required_one

  • opt_exclusive

  • load_config

  • find_scripts

FUNCTIONS

opt_required_one(\%opt_hash, @opt_names)

Fails by invoking pod2usage when none of the options in @opt_names are given in %opt_hash.

opt_required_all(\%opt_hash, @opt_names)

Fails by invoking pod2usage when any of the options in @opt_names are missing in %opt_hash.

opt_exclusive(\%opt_hash, @opt_names)

Fails by invoking pod2usage when more than one of the options in @opt_names are given in %opt_hash.

load_config(;\%opt_hash)

Tries to load the primary configuration. It looks in any directory returned by "config_dirs" in File::ConfigDir for files named either check_web or like the basename of the invoking script ($0) with any extension supported by Config::Any. The found configuration files are merged into a single configuration hash using Hash::Merge with the LEFT_PRECEDENT ruleset.

When an option hash is given, the default agent is computed based on the value of $opt_hash{file}.

find_scripts(\%cfg,@patterns)

Finds scripts based on configuration and given patterns.

  • When %cfg contains an array with full qualified path names below the script_dirs, those directories are scanned. When the directories are relative, the are concatenated using "config_dirs" in File::ConfigDir (each entry in the script_dirs is evaluated separately).

    When %cfg contains a string below the key script_dirs, the config_dirs($cfg{script_dirs}) is used to find the scripts.

    In any other case, config_dirs("check_web") is used.

  • The @patterns list must contain one or more file names or expandable shell patterns with or without directory parts and/or extensions.

    Valid entries are for example:

    -

    qw(check_host_app_one)

    -

    qw(check_host/app_one)

    -

    qw(check_host_app_one.json)

    -

    qw(check_host/app_one.yml)

    -

    qw(check_splunk_[1-5])

    -

    qw(splunk/test*)

Returns the list of found script file names.

BUGS

Please report any bugs or feature requests on the bugtracker website http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Mechanize-Script or by email to bug-www-mechanize-script@rt.cpan.org.

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

Jens Rehsack <rehsack@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Jens Rehsack.

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