1No::Worries(3) User Contributed Perl Documentation No::Worries(3)
2
3
4
6 No::Worries - coding without worries
7
9 use No::Worries qw($HostName $ProgramName);
10
11 printf("host is %s\n", $HostName);
12 printf("program is %s\n", $ProgramName);
13
15 This module and its sub-modules ease coding by providing consistent
16 convenient functions to perform frequently used programming tasks.
17
18 This module also exposes the $HostName and $ProgramName variables that
19 represent what the sub-modules think the host name or program name is.
20 These variables can be changed, if needed.
21
23 ERROR HANDLING
24 All the functions die() on error so one does not have to worry about
25 error checking: by default, any error will stop the code execution. The
26 recommended way to catch errors is to use eval().
27
28 For consistency, all the sub-modules use No::Worries::Die's dief() to
29 report errors and No::Worries::Warn's warnf() to report warnings. The
30 NO_WORRIES environment variable can be used to control how errors and
31 warnings are reported (see No::Worries::Die and No::Worries::Warn).
32
33 OPTION PASSING
34 All the functions use the same consistent API with hashes to pass
35 options like in:
36
37 dir_make("/tmp/some/path", mode => 0770);
38
39 This is a bit overkill when only one option is supported but it allows
40 adding options later without breaking old code.
41
42 The options can also be passed via a hash reference (this can be useful
43 to avoid data copying):
44
45 dir_make("/tmp/some/path", { mode => 0770 });
46
47 All the options are checked using Params::Validate.
48
49 SYMBOL IMPORTING
50 All the modules are "clean" in the sense that they do not import any
51 symbol into the caller's namespace. All the needed symbols (usually
52 functions) have to be explicitly imported like in:
53
54 use No::Worries::Die qw(dief);
55
56 In addition, all "normal" symbols can be imported at once using the
57 asterisk character:
58
59 use No::Worries::Log qw(*);
60
62 Here are the relevant sub-modules and what they provide:
63
64 No::Worries::Date - date handling:
65 • date_parse(STRING)
66
67 • date_stamp([TIME])
68
69 • date_string([TIME])
70
71 No::Worries::Die - error handling:
72 • dief(FORMAT, ARGUMENTS...)
73
74 No::Worries::Dir - directory handling:
75 • dir_change(PATH)
76
77 • dir_ensure(PATH[, OPTIONS])
78
79 • dir_make(PATH[, OPTIONS])
80
81 • dir_parent(PATH)
82
83 • dir_read(PATH)
84
85 • dir_remove(PATH)
86
87 No::Worries::DN - Distinguished Names handling:
88 • dn_parse(STRING)
89
90 • dn_string(DN, FORMAT)
91
92 No::Worries::Export - export control:
93 • export_control(CALLERPKG, PKG, EXPORT, NAMES...)
94
95 No::Worries::File - file handling:
96 • file_read(PATH[, OPTIONS])
97
98 • file_write(PATH[, OPTIONS])
99
100 • file_update(PATH[, OPTIONS])
101
102 No::Worries::Log - logging (log and filter information):
103 • log_filter(FILTER)
104
105 • log_configure(PATH)
106
107 • log_wants_error()
108
109 • log_wants_warning()
110
111 • log_wants_info()
112
113 • log_wants_debug()
114
115 • log_wants_trace()
116
117 • log_error(ARGUMENTS)
118
119 • log_warning(ARGUMENTS)
120
121 • log_info(ARGUMENTS)
122
123 • log_debug(ARGUMENTS)
124
125 • log_trace()
126
127 • log2std(INFO)
128
129 • log2dump(INFO)
130
131 No::Worries::PidFile - pid file handling:
132 • pf_set(PATH[, OPTIONS])
133
134 • pf_check(PATH[, OPTIONS])
135
136 • pf_unset(PATH)
137
138 • pf_touch(PATH)
139
140 • pf_sleep(PATH[, OPTIONS])
141
142 • pf_status(PATH[, OPTIONS])
143
144 • pf_quit(PATH[, OPTIONS])
145
146 No::Worries::Proc - process handling:
147 • proc_output(COMMAND...)
148
149 • proc_create(OPTIONS)
150
151 • proc_terminate(PROC[, OPTIONS])
152
153 • proc_monitor(PROCS[, OPTIONS])
154
155 • proc_run(OPTIONS)
156
157 • proc_detach([OPTIONS])
158
159 • proc_status(STATUS)
160
161 No::Worries::Stat - file status handling:
162 • stat_ensure(PATH[, OPTIONS])
163
164 • stat_type(MODE)
165
166 No::Worries::String - string handling:
167 • string_bytefmt(NUMBER[, PRECISION])
168
169 • string_escape(STRING)
170
171 • string_plural(STRING)
172
173 • string_quantify(NUMBER, STRING)
174
175 • string_table(TABLE[, OPTIONS])
176
177 • string_trim(STRING)
178
179 No::Worries::Syslog - syslog handling:
180 • syslog_open([OPTIONS])
181
182 • syslog_close()
183
184 • syslog_sanitize(STRING)
185
186 • syslog_debug(FORMAT, ARGUMENTS...)
187
188 • syslog_info(FORMAT, ARGUMENTS...)
189
190 • syslog_warning(FORMAT, ARGUMENTS...)
191
192 • syslog_error(FORMAT, ARGUMENTS...)
193
194 • log2syslog(INFO)
195
196 No::Worries::Warn - warning handling:
197 • warnf(FORMAT, ARGUMENTS...)
198
200 The No::Worries::Die and No::Worries::Warn modules use the "NO_WORRIES"
201 environment variable to control how errors and warnings should be
202 reported.
203
205 This module uses the following global variables (that can all be
206 imported):
207
208 $HostName
209 the name of the host this program runs on (default: derived from
210 Sys::Hostname)
211
212 $ProgramName
213 the name of the program currently running (default: derived from
214 $0)
215
217 No::Worries::Date, No::Worries::Die, No::Worries::Dir, No::Worries::DN,
218 No::Worries::Export, No::Worries::File, No::Worries::Log,
219 No::Worries::PidFile, No::Worries::Proc, No::Worries::Stat,
220 No::Worries::String, No::Worries::Syslog, No::Worries::Warn,
221 Params::Validate.
222
224 Lionel Cons <http://cern.ch/lionel.cons>
225
226 Copyright (C) CERN 2012-2019
227
228
229
230perl v5.34.0 2021-10-18 No::Worries(3)