NAME

No::Worries - coding without worries

SYNOPSIS

use No::Worries qw($HostName $ProgramName);

printf("host is %s\n", $HostName);
printf("program is %s\n", $ProgramName);

DESCRIPTION

This module and its sub-modules ease coding by providing consistent convenient functions to perform frequently used programming tasks.

This module also exposes the $HostName and $ProgramName variables that represent what the sub-modules think the host name or program name is. These variables can be changed, if needed.

PROGRAMMING STYLE

ERROR HANDLING

All the functions die() on error so one does not have to worry about error checking: by default, any error will stop the code execution. The recommended way to catch errors is to use eval().

For consistency, all the sub-modules use No::Worries::Die's dief() to report errors and No::Worries::Warn's warnf() to report warnings. The NO_WORRIES environment variable can be used to control how errors and warnings are reported (see No::Worries::Die and No::Worries::Warn).

OPTION PASSING

All the functions use the same consistent API with hashes to pass options like in:

dir_make("/tmp/some/path", mode => 0770);

This is a bit overkill when only one option is supported but it allows adding options later without breaking old code.

The options can also be passed via a hash reference (this can be useful to avoid data copying):

dir_make("/tmp/some/path", { mode => 0770 });

All the options are checked using Params::Validate.

SYMBOL IMPORTING

All the modules are "clean" in the sense that they do not import any symbol into the caller's namespace. All the needed symbols (usually functions) have to be explicitly imported like in:

use No::Worries::Die qw(dief);

In addition, all "normal" symbols can be imported at once using the asterisk character:

use No::Worries::Log qw(*);

MODULES

Here are the relevant sub-modules and what they provide:

No::Worries::Date - date handling:
  • date_parse(STRING)

  • date_stamp([TIME])

  • date_string([TIME])

No::Worries::Die - error handling:
  • dief(FORMAT, ARGUMENTS...)

No::Worries::Dir - directory handling:
  • dir_change(PATH)

  • dir_ensure(PATH[, OPTIONS])

  • dir_make(PATH[, OPTIONS])

  • dir_parent(PATH)

  • dir_read(PATH)

  • dir_remove(PATH)

No::Worries::DN - Distinguished Names handling:
  • dn_parse(STRING)

  • dn_string(DN, FORMAT)

No::Worries::Export - export control:
  • export_control(CALLERPKG, PKG, EXPORT, NAMES...)

No::Worries::File - file handling:
  • file_read(PATH[, OPTIONS])

  • file_write(PATH[, OPTIONS])

  • file_update(PATH[, OPTIONS])

No::Worries::Log - logging (log and filter information):
  • log_filter(FILTER)

  • log_configure(PATH)

  • log_wants_error()

  • log_wants_warning()

  • log_wants_info()

  • log_wants_debug()

  • log_wants_trace()

  • log_error(ARGUMENTS)

  • log_warning(ARGUMENTS)

  • log_info(ARGUMENTS)

  • log_debug(ARGUMENTS)

  • log_trace()

  • log2std(INFO)

  • log2dump(INFO)

No::Worries::PidFile - pid file handling:
  • pf_set(PATH[, OPTIONS])

  • pf_check(PATH[, OPTIONS])

  • pf_unset(PATH)

  • pf_touch(PATH)

  • pf_sleep(PATH[, OPTIONS])

  • pf_status(PATH[, OPTIONS])

  • pf_quit(PATH[, OPTIONS])

No::Worries::Proc - process handling:
  • proc_output(COMMAND...)

  • proc_create(OPTIONS)

  • proc_terminate(PROC[, OPTIONS])

  • proc_monitor(PROCS[, OPTIONS])

  • proc_run(OPTIONS)

  • proc_detach([OPTIONS])

  • proc_status(STATUS)

No::Worries::Stat - file status handling:
  • stat_ensure(PATH[, OPTIONS])

  • stat_type(MODE)

No::Worries::String - string handling:
  • string_bytefmt(NUMBER[, PRECISION])

  • string_escape(STRING)

  • string_plural(STRING)

  • string_quantify(NUMBER, STRING)

  • string_table(TABLE[, OPTIONS])

  • string_trim(STRING)

No::Worries::Syslog - syslog handling:
  • syslog_open([OPTIONS])

  • syslog_close()

  • syslog_sanitize(STRING)

  • syslog_debug(FORMAT, ARGUMENTS...)

  • syslog_info(FORMAT, ARGUMENTS...)

  • syslog_warning(FORMAT, ARGUMENTS...)

  • syslog_error(FORMAT, ARGUMENTS...)

  • log2syslog(INFO)

No::Worries::Warn - warning handling:
  • warnf(FORMAT, ARGUMENTS...)

ENVIRONMENT VARIABLES

The No::Worries::Die and No::Worries::Warn modules use the NO_WORRIES environment variable to control how errors and warnings should be reported.

GLOBAL VARIABLES

This module uses the following global variables (that can all be imported):

$HostName

the name of the host this program runs on (default: derived from Sys::Hostname)

$ProgramName

the name of the program currently running (default: derived from $0)

SEE ALSO

No::Worries::Date, No::Worries::Die, No::Worries::Dir, No::Worries::DN, No::Worries::Export, No::Worries::File, No::Worries::Log, No::Worries::PidFile, No::Worries::Proc, No::Worries::Stat, No::Worries::String, No::Worries::Syslog, No::Worries::Warn, Params::Validate.

AUTHOR

Lionel Cons http://cern.ch/lionel.cons

Copyright (C) CERN 2012-2019