Cmdline.pm
NAME
Communiware::CmdLine - common procedures for Communiware command-line tools
SYNOPSIS
cmwuser($site); help();
DESCRIPTION
This module contain common functions to be used by all Communiware command-line tools
FUNCTIONS
cmwuser
This function moved to Communiware::Auth;
say
Implements the Perl 6 say
(print
-with-newline) function.
Borrowed from Perl6::Say.
SYNOPSIS
# Perl 5 code... use Communiware::Cmdline qw(say); say 'boo'; # same as: print 'boo', "\n" say STDERR 'boo'; # same as: print STDERR 'boo', "\n" STDERR->say('boo'); # same as: print STDERR 'boo', \n" $fh->say('boo'); # same as: print $fh 'boo', "\n";
DESCRIPTION
Implements a close simulation of say
, the Perl 6 print-with-newline
function.
Use it just like print
(except that it only supports the indirect object
syntax when the stream is a bareword). That is, assuming the relevant
filehandles are open for output, you can use any of these:
say @data; say FH @data; say $fh, @data; FH->say(@data); *FH->say(@data); (\*FH)->say(@data); $fh->say(@data);
but not any of these:
say {FH} @data; say {*FH} @data; say {\*FH} @data; say $fh @data; say {$fh} @data;
Interaction with output record separator
In Perl 6, say @stuff
is exactly equivalent to
Core::print @stuff, "\n"
.
That means that a call to say
appends any output record separator
after the added newline (though in Perl 6, the ORS is an attribute of
the filehandle being used, rather than a glonal $/
variable).
help
Obsolete, please use process_options or print_usage functions.
process_options
SYNOPSIS
use Communiware::Cmdline qw(process_options);
## hase with default values my %options = { verbose => 'info'}; my @options_specs = ('config=s', 'encoding=s', 'someoption'); process_options(\%options, @options_specs);
or simple my %options = process_options(undef, ['config=s', 'encoding=s', 'someoption']);
Communiware::init(config => $options{'config'}, loglevel => $options{'verbose'});
DESCRIPTION
Process commang line options. Gets reference to options hash and array of options specs. For details about options specification formats see Getopt::Long.
Handles --help, -h and --man options - print a usage message from embedded pod documentation.
Handles --config option - get config file name from command line.
Handles --verbose option - get verbosivity level from command line, default
'warn'. See Communiware::Logger
for more info about loglevels.
Accepts some configuration options: 1. dump_options - dumps options hash after processing (for debugging). Also you can use environment variable DUMP_OPTIONS.
print_usage
Invokes perldoc on the current script.
SYNOPSIS
print_usage()
DESCRIPTION
Passes all arguments to Pod::Usage::pod2usage.