Venus
OO Library
OO Standard Library for Perl 5
function: cast function: catch function: caught function: error function: false function: fault function: raise function: true
package main;
use Venus qw(
catch
error
raise
);
# error handling
my ($error, $result) = catch {
error;
};
# boolean keywords
if ($result and $result eq false) {
true;
}
# raise exceptions
if (false) {
raise 'MyApp::Error';
}
# and much more!
true ne false;
This library provides an object-orientation framework and extendible standard library for Perl 5, built on top of the Mars architecture with classes which wrap most native Perl data types. Venus has a simple modular architecture, robust library of classes, methods, and roles, supports pure-Perl autoboxing, advanced exception handling, "true" and "false" functions, package introspection, command-line options parsing, and more. This package will always automatically exports true and false keyword functions (unless existing routines of the same name already exist in the calling package or its parents), otherwise exports keyword functions as requested at import. This library requires Perl 5.18+.
The cast function returns the argument provided as an object, promoting native Perl data types to data type objects. The optional second argument can be the name of the type for the object to cast to explicitly.
cast(Any $data, Str $type) (Object)
{ since => '1.40', }
=example-1 cast
package main;
use Venus 'cast';
my $undef = cast;
# bless({value => undef}, "Venus::Undef")
The catch function executes the code block trapping errors and returning the caught exception in scalar context, and also returning the result as a second argument in list context.
catch(CodeRef $block) (Error, Any)
{ since => '0.01', }
=example-1 catch
package main;
use Venus 'catch';
my $error = catch {die};
$error;
# "Died at ..."
The caught function evaluates the exception object provided and validates its identity and name (if provided) then executes the code block provided returning the result of the callback. If no callback is provided this function returns the exception object on success and undef on failure.
caught(Object $error, Str | Tuple[Str, Str] $identity, CodeRef $block) (Any)
{ since => '1.95', }
=example-1 caught
package main;
use Venus 'catch', 'caught', 'error';
my $error = catch { error };
my $result = caught $error, 'Venus::Error';
# bless(..., 'Venus::Error')
The error function throws a Venus::Error exception object using the exception object arguments provided.
error(Maybe[HashRef] $args) (Error)
{ since => '0.01', }
=example-1 error
package main;
use Venus 'error';
my $error = error;
# bless({...}, 'Venus::Error')
The false function returns a falsy boolean value which is designed to be practically indistinguishable from the conventional numerical 0 value.
false() (Bool)
{ since => '0.01', }
=example-1 false
package main;
use Venus;
my $false = false;
# 0
The fault function throws a Venus::Fault exception object and represents a system failure, and isn't meant to be caught.
fault(Str $args) (Fault)
{ since => '1.80', }
=example-1 fault
package main;
use Venus 'fault';
my $fault = fault;
# bless({message => 'Exception!'}, 'Venus::Fault')
The raise function generates and throws a named exception object derived from Venus::Error, or provided base class, using the exception object arguments provided.
raise(Str $class | Tuple[Str, Str] $class, Maybe[HashRef] $args) (Error)
{ since => '0.01', }
=example-1 raise
package main;
use Venus 'raise';
my $error = raise 'MyApp::Error';
# bless({...}, 'MyApp::Error')
The true function returns a truthy boolean value which is designed to be practically indistinguishable from the conventional numerical 1 value.
true() (Bool)
{ since => '0.01', }
=example-1 true
package main;
use Venus;
my $true = true;
# 1
This library provides a Perl object-oriented standard library with value classes and consistently named methods.
This library provides value classes which wrap native Perl data types and provides methods for operating their values.
This library provides opt-in pure Perl autoboxing allowing you to chain methods calls across objects and values.
This library provides serveral essential utility classes for performing common programming tasks.
This library provides a package reflection class, Venus::Space, which can be used to perform meta-programming on package spaces.
This library provides a framework for raising, i.e. generating and throwing, exception objects and catching them.
This library provides a library of composable roles which can be used to extend core behaviors to custom objects.
This library provides a mechanism for extending the standard library, i.e. value classes, using plugins which can be automatically discovered and invoked. (no monkey-patching necessary)
This library provides a minimalistic templating system.
Awncorp, awncorp@cpan.org
Copyright (C) 2000, Al Newkirk.
This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.
97 POD Errors
The following errors were encountered while parsing the POD:
- Around line 13:
Unknown directive: =name
- Around line 21:
Unknown directive: =tagline
- Around line 29:
Unknown directive: =abstract
- Around line 37:
Unknown directive: =includes
- Around line 52:
Unknown directive: =synopsis
- Around line 89:
Unknown directive: =description
- Around line 106:
Unknown directive: =function
- Around line 112:
Unknown directive: =signature
- Around line 116:
Unknown directive: =metadata
- Around line 152:
=cut found outside a pod block. Skipping to next block.
- Around line 175:
=cut found outside a pod block. Skipping to next block.
- Around line 195:
=cut found outside a pod block. Skipping to next block.
- Around line 206:
Unknown directive: =function
- Around line 212:
Unknown directive: =signature
- Around line 216:
Unknown directive: =metadata
- Around line 256:
=cut found outside a pod block. Skipping to next block.
- Around line 278:
=cut found outside a pod block. Skipping to next block.
- Around line 288:
Unknown directive: =function
- Around line 295:
Unknown directive: =signature
- Around line 299:
Unknown directive: =metadata
- Around line 340:
=cut found outside a pod block. Skipping to next block.
- Around line 364:
=cut found outside a pod block. Skipping to next block.
- Around line 388:
=cut found outside a pod block. Skipping to next block.
- Around line 413:
=cut found outside a pod block. Skipping to next block.
- Around line 434:
=cut found outside a pod block. Skipping to next block.
- Around line 455:
=cut found outside a pod block. Skipping to next block.
- Around line 476:
=cut found outside a pod block. Skipping to next block.
- Around line 497:
=cut found outside a pod block. Skipping to next block.
- Around line 524:
=cut found outside a pod block. Skipping to next block.
- Around line 537:
Unknown directive: =function
- Around line 542:
Unknown directive: =signature
- Around line 546:
Unknown directive: =metadata
- Around line 586:
=cut found outside a pod block. Skipping to next block.
- Around line 598:
Unknown directive: =function
- Around line 603:
Unknown directive: =signature
- Around line 607:
Unknown directive: =metadata
- Around line 643:
=cut found outside a pod block. Skipping to next block.
- Around line 652:
Unknown directive: =function
- Around line 657:
Unknown directive: =signature
- Around line 661:
Unknown directive: =metadata
- Around line 699:
=cut found outside a pod block. Skipping to next block.
- Around line 711:
Unknown directive: =function
- Around line 717:
Unknown directive: =signature
- Around line 721:
Unknown directive: =metadata
- Around line 760:
=cut found outside a pod block. Skipping to next block.
- Around line 785:
=cut found outside a pod block. Skipping to next block.
- Around line 798:
Unknown directive: =function
- Around line 803:
Unknown directive: =signature
- Around line 807:
Unknown directive: =metadata
- Around line 843:
=cut found outside a pod block. Skipping to next block.
- Around line 852:
Unknown directive: =feature
- Around line 895:
=cut found outside a pod block. Skipping to next block.
- Around line 904:
Unknown directive: =feature
- Around line 923:
=cut found outside a pod block. Skipping to next block.
- Around line 942:
=cut found outside a pod block. Skipping to next block.
- Around line 961:
=cut found outside a pod block. Skipping to next block.
- Around line 980:
=cut found outside a pod block. Skipping to next block.
- Around line 999:
=cut found outside a pod block. Skipping to next block.
- Around line 1018:
=cut found outside a pod block. Skipping to next block.
- Around line 1037:
=cut found outside a pod block. Skipping to next block.
- Around line 1056:
=cut found outside a pod block. Skipping to next block.
- Around line 1075:
=cut found outside a pod block. Skipping to next block.
- Around line 1094:
=cut found outside a pod block. Skipping to next block.
- Around line 1103:
Unknown directive: =feature
- Around line 1124:
=cut found outside a pod block. Skipping to next block.
- Around line 1133:
Unknown directive: =feature
- Around line 1152:
=cut found outside a pod block. Skipping to next block.
- Around line 1171:
=cut found outside a pod block. Skipping to next block.
- Around line 1190:
=cut found outside a pod block. Skipping to next block.
- Around line 1209:
=cut found outside a pod block. Skipping to next block.
- Around line 1228:
=cut found outside a pod block. Skipping to next block.
- Around line 1247:
=cut found outside a pod block. Skipping to next block.
- Around line 1266:
=cut found outside a pod block. Skipping to next block.
- Around line 1285:
=cut found outside a pod block. Skipping to next block.
- Around line 1304:
=cut found outside a pod block. Skipping to next block.
- Around line 1323:
=cut found outside a pod block. Skipping to next block.
- Around line 1342:
=cut found outside a pod block. Skipping to next block.
- Around line 1361:
=cut found outside a pod block. Skipping to next block.
- Around line 1380:
=cut found outside a pod block. Skipping to next block.
- Around line 1399:
=cut found outside a pod block. Skipping to next block.
- Around line 1418:
=cut found outside a pod block. Skipping to next block.
- Around line 1437:
=cut found outside a pod block. Skipping to next block.
- Around line 1456:
=cut found outside a pod block. Skipping to next block.
- Around line 1475:
=cut found outside a pod block. Skipping to next block.
- Around line 1495:
=cut found outside a pod block. Skipping to next block.
- Around line 1505:
Unknown directive: =feature
- Around line 1526:
=cut found outside a pod block. Skipping to next block.
- Around line 1535:
Unknown directive: =feature
- Around line 1568:
=cut found outside a pod block. Skipping to next block.
- Around line 1577:
Unknown directive: =feature
- Around line 1605:
=cut found outside a pod block. Skipping to next block.
- Around line 1614:
Unknown directive: =feature
- Around line 1650:
=cut found outside a pod block. Skipping to next block.
- Around line 1659:
Unknown directive: =feature
- Around line 1685:
=cut found outside a pod block. Skipping to next block.
- Around line 1694:
Unknown directive: =authors
- Around line 1702:
Unknown directive: =license