WA2L::Util
Package: WA2L/edrc 1.5.57
Section: Library Functions (3)
Updated: 27 December 2021
Index
Return to Main Contents
NAME
WA2L::Util - General WA2L/edrc Utility Functions Perl Module
SYNOPSIS
Initialize environment (see also:
perlenv(3)
for a description of how to initialize the environment and
how to start a Perl program):
-
[ /home/fred ]
[ fred@acme-007 ][bash]: eval `~edrc/lib/perlenv`
Perl program using
WA2L::Util:
-
#!/usr/bin/env perl
use WA2L::Util;
use File::Basename;
$ENV{EDRC_LOGFILE} = approot() . "/var/log/" .
basename($0) . ".log";
# print message
#
msg( level => "INFO", txt => "start script" );
# create a log file entry
#
log( level => "INFO", txt => "start script" );
# print timestamp
#
print now() . "\n";
# check options
#
checkopt(
used_opts=>"fv",
truthtable => "
fnv
100
101
110
"
) or die('Usage: ' . basename $0 . ' -f file [ -n | -v ]');
AVAILABILITY
WA2L/edrc
DESCRIPTION
This is a collection of general WA2L/edrc utility functions to
be used in Perl scripts or other Perl modules.
FUNCTIONS
- msg( level => LEVEL, txt => text )
-
print a standardized message text to
stderr.
See
msg(3)
for the message format.
- log( level => LEVEL, txt => text )
-
write a standardized message text to the log file
specified in the
$EDRC_LOGFILE
environment variable. The session can be set in the
$EDRC_SESSION.
If
$EDRC_SESSION
is not set, the process ID of the calling Perl script
is used as a ad-hoc session id.
See
log(3)
for the output format.
- now()
-
return the current date and time in the military format
YYYY-MM-DD hh:mm:ss.
- approot()
-
return the root of the WA2L/edrc package installation.
The output is identical to the
approot(3)
command.
- checkopt( used_opts => options, truthtable => table )
-
check if a list of used
options
matches against a
table
of allowed option combinations.
This command is intended to be used to efficiently parse arguments in a script.
The
checkopt
function returns
1
(=true) if
options
are correct,
0
(=false) if
options
are not correct.
See
checkopt(3)
for the detail description.
ENVIRONMENT
- $EDRC_SESSION
-
session name.
- $EDRC_LOGFILE
-
log file name and path.
EXIT STATUS
-
FILES
- edrc/lib/perl/pm/perl*/vendor_perl/WA2L/Util.pm
-
this Perl module file.
EXAMPLES
-
SEE ALSO
edrcintro(1)
perl(1),
perlenv(3),
perl_modules(3)
NOTES
-
BUGS
-
AUTHOR
WA2L::Util was developed by Christian Walther. Send suggestions
and bug reports to wa2l@users.sourceforge.net .
COPYRIGHT
Copyright © 2021
Christian Walther
This is free software; see
edrc/doc/COPYING
for copying conditions. There is ABSOLUTELY NO WARRANTY; not
even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This document was created by man2html
using the manual pages.
Time: 16:55:04 GMT, August 28, 2024