perlcompat Package
perlcompat - Perl-like utility functions such as warn, die, getopt, and require.
DESCRIPTION
This manual page documents perlcompat module, a Python module providing Perl-like utility functions such as warn, die, getopt, and require.
Perl programmers are generally familiar with Perl's useful buil-in functions such as warn() and die() for displaying debug/error messages as well as its standard modules such as Getopt::Std for parsing UNIX-style command-line options.
perlcompat module provides several utility fucntions with functionarites similar to Perl's counterparts.
EXAMPLE
import os
import sys
from perlcompat import warn, die, getopts, require
# make sure the Python is no older than version 3.6
require('3.6')
# display warning message
warn('starting of sample program in directory {}...'.format(os.getcwd()))
# parse command-line options
# variables opt.v, opt.f, and opt.o are automatically defined
opt = getopts('vf:o:') or die('usage: {} [-v] [-f config] [-o outfile]'.format(sys.argv[0]))
if opt.v:
warn('verbose mode')
if opt.f:
conffile = opt.f if opt.f else 'config.ini'
warn('config file: {}'.format(conffile))
if opt.o:
outfile = opt.o if opt.o else 'out.txt'
warn('output file: {}'.format(outfile))
warn('remaining arguments: {}'.format(sys.argv[1:]))
FUNCTIONS
perlcompat module provides the following functions.
-
warn(astr)
Display warning message ASTR to the standard error output.
-
die(astr)
Display message ASTR to the standard error output and terminate the program execution
-
getopts(spec)
Parse UNIX-style command line options. Options are specified by SPEC. Parsed options are returned as an object. A value for option X is accessible trhough the object attribute X.
perlcompat module only supports short options (e.g., -v, -f foo.txt). Log options (e..g, --verbose, --file foo.txt) are not suported.
-
require(version)
Abort the program if the current Python interepter does not satisfy version requirement (i.e., the version is older than VERSION).
INSTALLATION
pip3 install perlcompat
AVAILABILITY
The latest version of perlcompat module is available at PyPI (https://pypi.org/project/perlcompat/) .
SEE ALSO
perl(1), perlfunc(1), getopt(3), Getopt::Std(3perl)
AUTHOR
Hiroyuki Ohsaki <code[atmark]lsnl.jp>
Metadata
Release files for perlcompat 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| perlcompat-1.2.tar.gz | 15.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| perlcompat-1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.6 kB
Release files / perlcompat-1.2.tar.gz
| Download URL | perlcompat-1.2.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b54572644a0ef87818ca3db242b0be76f86a6c349b65139f3fa1f998161425da
|
|
BLAKE2b-256 checksum How to use checksums |
c92a1a39030ce0ef80386403d5db6330a1752f5027158bf686cfa712e0898f5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / perlcompat-1.2-py3-none-any.whl
| Download URL | perlcompat-1.2-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
95a7c915d8bed6ed520232331c4a6f5fdad8411b2ba1c3dd5de3a0bd923de764
|
|
BLAKE2b-256 checksum How to use checksums |
36aec8ff593db0ccdaaca21b420a17de04d4609277be266d10987eb44a11585c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for perlcompat 1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.