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 No::Worries::Log - logging (log and filter information):
101 · log_filter(FILTER)
102
103 · log_configure(PATH)
104
105 · log_wants_error()
106
107 · log_wants_warning()
108
109 · log_wants_info()
110
111 · log_wants_debug()
112
113 · log_wants_trace()
114
115 · log_error(ARGUMENTS)
116
117 · log_warning(ARGUMENTS)
118
119 · log_info(ARGUMENTS)
120
121 · log_debug(ARGUMENTS)
122
123 · log_trace()
124
125 · log2std(INFO)
126
127 · log2dump(INFO)
128
129 No::Worries::PidFile - pid file handling:
130 · pf_set(PATH[, OPTIONS])
131
132 · pf_check(PATH[, OPTIONS])
133
134 · pf_unset(PATH)
135
136 · pf_touch(PATH)
137
138 · pf_sleep(PATH[, OPTIONS])
139
140 · pf_status(PATH[, OPTIONS])
141
142 · pf_quit(PATH[, OPTIONS])
143
144 No::Worries::Proc - process handling:
145 · proc_output(COMMAND...)
146
147 · proc_create(OPTIONS)
148
149 · proc_terminate(PROC[, OPTIONS])
150
151 · proc_monitor(PROCS[, OPTIONS])
152
153 · proc_run(OPTIONS)
154
155 · proc_detach([OPTIONS])
156
157 No::Worries::Stat - file status handling:
158 · stat_ensure(PATH[, OPTIONS])
159
160 · stat_type(MODE)
161
162 No::Worries::String - string handling:
163 · string_bytefmt(NUMBER[, PRECISION])
164
165 · string_escape(STRING)
166
167 · string_plural(STRING)
168
169 · string_quantify(NUMBER, STRING)
170
171 · string_table(TABLE[, OPTIONS])
172
173 · string_trim(STRING)
174
175 No::Worries::Syslog - syslog handling:
176 · syslog_open([OPTIONS])
177
178 · syslog_close()
179
180 · syslog_sanitize(STRING)
181
182 · syslog_debug(FORMAT, ARGUMENTS...)
183
184 · syslog_info(FORMAT, ARGUMENTS...)
185
186 · syslog_warning(FORMAT, ARGUMENTS...)
187
188 · syslog_error(FORMAT, ARGUMENTS...)
189
190 · log2syslog(INFO)
191
192 No::Worries::Warn - warning handling:
193 · warnf(FORMAT, ARGUMENTS...)
194
196 The No::Worries::Die and No::Worries::Warn modules use the "NO_WORRIES"
197 environment variable to control how errors and warnings should be
198 reported.
199
201 This module uses the following global variables (that can all be
202 imported):
203
204 $HostName
205 the name of the host this program runs on (default: derived from
206 Sys::Hostname)
207
208 $ProgramName
209 the name of the program currently running (default: derived from
210 $0)
211
213 No::Worries::Date, No::Worries::Die, No::Worries::Dir, No::Worries::DN,
214 No::Worries::Export, No::Worries::File, No::Worries::Log,
215 No::Worries::PidFile, No::Worries::Proc, No::Worries::Stat,
216 No::Worries::String, No::Worries::Syslog, No::Worries::Warn,
217 Params::Validate.
218
220 Lionel Cons <http://cern.ch/lionel.cons>
221
222 Copyright (C) CERN 2012-2017
223
224
225
226perl v5.28.0 2017-08-01 No::Worries(3)