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

NAME

No::Worries - coding without worries

SYNOPSIS

  use No::Worries qw($ProgramName);

  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 $ProgramName variable that represents what the modules think the program name is. This variable 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::File - file handling:
  • file_read(PATH[, OPTIONS])

  • file_write(PATH[, OPTIONS])

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

  • log_debug(ARGUMENTS)

  • log_info(ARGUMENTS)

  • log_warning(ARGUMENTS)

  • log_error(ARGUMENTS)

  • log_wants_trace()

  • log_wants_debug()

  • log_wants_info()

  • log_wants_warning()

  • log_wants_error()

  • log_filter(FILTER)

  • log_configure(PATH)

  • log2std(INFO)

  • log2dump(INFO)

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

  • pf_check(PATH[, OPTIONS])

  • pf_touch(PATH)

  • pf_unset(PATH)

  • 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])

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

GLOBAL VARIABLES

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

$ProgramName

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

SEE ALSO

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

AUTHOR

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

Copyright CERN 2012