Acme-Perl-Consensual
view release on metacpan or search on metacpan
CONTRIBUTING view on Meta::CPAN
a stable state, so it would be a waste of time translating them.
Coding Style
I tend to write using something approximating the Allman style, using
tabs for indentation and Unix-style line breaks.
* <http://en.wikipedia.org/wiki/Indent_style#Allman_style>
* <http://www.derkarl.org/why_to_tabs.html>
I nominally encode all source files as UTF-8, though in practice most of
them use a 7-bit-safe ASCII-compatible subset of UTF-8.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
Copyright (c) 2012-2013 by Toby Inkster.
CONTRIBUTING.pod is licensed under the Creative Commons
Attribution-ShareAlike 2.0 UK: England & Wales License. To view a copy
of this license, visit
inc/YAML/Tiny.pm view on Meta::CPAN
package YAML::Tiny;
use strict;
# UTF Support?
sub HAVE_UTF8 () { $] >= 5.007003 }
BEGIN {
if ( HAVE_UTF8 ) {
# The string eval helps hide this from Test::MinimumVersion
eval "require utf8;";
die "Failed to load UTF-8 support" if $@;
}
# Class structure
require 5.004;
require Exporter;
require Carp;
$YAML::Tiny::VERSION = '1.51';
# $YAML::Tiny::VERSION = eval $YAML::Tiny::VERSION;
@YAML::Tiny::ISA = qw{ Exporter };
@YAML::Tiny::EXPORT = qw{ Load Dump };
inc/YAML/Tiny.pm view on Meta::CPAN
my $self = bless [], $class;
my $string = $_[0];
eval {
unless ( defined $string ) {
die \"Did not provide a string to load";
}
# Byte order marks
# NOTE: Keeping this here to educate maintainers
# my %BOM = (
# "\357\273\277" => 'UTF-8',
# "\376\377" => 'UTF-16BE',
# "\377\376" => 'UTF-16LE',
# "\377\376\0\0" => 'UTF-32LE'
# "\0\0\376\377" => 'UTF-32BE',
# );
if ( $string =~ /^(?:\376\377|\377\376|\377\376\0\0|\0\0\376\377)/ ) {
die \"Stream has a non UTF-8 BOM";
} else {
# Strip UTF-8 bom if found, we'll just ignore it
$string =~ s/^\357\273\277//;
}
# Try to decode as utf8
utf8::decode($string) if HAVE_UTF8;
# Check for some special cases
return $self unless length $string;
unless ( $string =~ /[\012\015]+\z/ ) {
die \"Stream does not end with newline character";
lib/Acme/Perl/Consensual.pm view on Meta::CPAN
)),
"mx-mex" => { age => 15 },
"mx-nay" => { puberty => 1 },
);
my %perlhist;
sub new
{
my ($class, %args) = @_;
$args{locale} = $ENV{LC_ALL} || $ENV{LC_LEGAL} || 'en_XX.UTF-8'
unless exists $args{locale};
$args{locale} = $1
if $args{locale} =~ /^.._(.+?)(\.|$)/;
bless \%args => $class;
}
sub locale
{
lc shift->{locale};
}
t/02-check-req.t view on Meta::CPAN
use Acme::Perl::Consensual;
my $gb = Acme::Perl::Consensual->new(locale => 'gb');
ok(not $gb->can(age => 6));
ok( $gb->can(age => 16));
ok( $gb->can(age => 26));
ok( $gb->can(age => 26, married => 0));
ok( $gb->can(age => 26, married => 1));
my $bo = Acme::Perl::Consensual->new(locale => 'tn_BO.UTF-8');
ok(not defined $bo->can(age => 16));
ok(not defined $bo->can(age => 26));
ok( $bo->can(age => 12, puberty => 1));
ok(not $bo->can(age => 12, puberty => 0));
ok($bo->can('locale'));
( run in 1.102 second using v1.01-cache-2.11-cpan-49f99fa48dc )