No::Worries(3)

๐Ÿ“ฆ
version 1.7 ยท 4 versions
, in epel 9

๐Ÿ’… No::Worries(3) โ€” coding without worries โœจ

okay so bestie, this is a page from the User Contributed Perl Documentation, and honestly? it ate. it's the manual for No::Worries, and no cap, the name is not a lie ๐Ÿซถ


๐ŸŒธ 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);

that's literally it, she's lowkey effortless ๐Ÿ˜ญ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So this module and all its sub-modules exist to make your coding life easier, by giving you consistent, convenient functions for the programming tasks you keep doing over and over. it's giving "why do it manually when you don't have to" energy ๐Ÿ’…

This module also exposes the $HostName and $ProgramName variables, which represent what the sub-modules think the host name or program name is. and yes โ€” you can change them if you need to. main character variables, honestly ๐Ÿ‘‘


๐ŸŽ€ PROGRAMMING STYLE ๐ŸŽ€

๐Ÿ’€ ERROR HANDLING ๐Ÿ’€

Okay so this is the big one: all the functions die() on error, so you literally never have to worry about error checking. by default, any error will just stop the code execution โ€” periodt. the recommended way to catch errors is to use eval(). iconic.

For consistency (and we love consistency), all the sub-modules use No::Worries::Die's dief() to report errors, and No::Worries::Warn's warnf() to report warnings. and! the NO_WORRIES environment variable can be used to control how errors and warnings are reported โ€” see No::Worries::Die and No::Worries::Warn for the deets ๐Ÿ‘€

๐ŸŒˆ OPTION PASSING ๐ŸŒˆ

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

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

ngl, this is a bit overkill when only one option is supported, but it means options can be added later without breaking old code. future-proof queen โœจ

The options can also be passed via a hash reference (which is useful when you want to avoid data copying):

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

All the options are checked using Params::Validate. no vibes-based validation here, we check ๐Ÿซถ

๐Ÿงš SYMBOL IMPORTING ๐Ÿงš

All the modules are "clean" โ€” meaning they do NOT import any symbol into the caller's namespace. every symbol you need (usually functions) has to be explicitly imported, like:

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(*);

one asterisk and you get the whole fit ๐Ÿ‘‘ it's giving deluxe bundle


๐Ÿ‘‘ MODULES ๐Ÿ‘‘

Here are the relevant sub-modules and what they provide โ€” bestie, this list is long but every single one matters ๐Ÿ’–

๐Ÿ“… 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. one env var to rule them all ๐Ÿ’…


โญ GLOBAL VARIABLES โญ

This module uses the following global variables โ€” and guess what, they 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.

like a whole friend group, fr fr ๐Ÿซถ


๐Ÿ’œ AUTHOR ๐Ÿ’œ

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

Copyright (C) CERN 2012-2019


and that's the whole page, bestie ๐ŸŽ€ this one's running on perl v5.32.1, dated 2021-10-18 โ€” so it's a vintage, and it still slays โœจ๐ŸŒธ๐Ÿ’–

๐Ÿ“ฆ where this page comes from