jsonpretty
view release on metacpan or search on metacpan
script/jsonpretty view on Meta::CPAN
Provides a C<catch> statement, but properly calling C<eval> is your
responsibility.
The C<try> keyword pushes C<$@> onto an error stack, avoiding some of the
issues with C<$@>, but you still need to localize to prevent clobbering.
=back
=head1 LIGHTNING TALK
I gave a lightning talk about this module, you can see the slides (Firefox
only):
L<http://nothingmuch.woobling.org/talks/takahashi.xul?data=yapc_asia_2009/try_tiny.txt>
Or read the source:
L<http://nothingmuch.woobling.org/talks/yapc_asia_2009/try_tiny.yml>
=head1 VERSION CONTROL
L<http://github.com/nothingmuch/try-tiny/>
=head1 AUTHOR
Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
=head1 COPYRIGHT
Copyright (c) 2009 Yuval Kogman. All rights reserved.
This program is free software; you can redistribute
it and/or modify it under the terms of the MIT license.
=cut
TRY_TINY
$fatpacked{"strictures.pm"} = <<'STRICTURES';
package strictures;
use strict;
use warnings FATAL => 'all';
our $VERSION = '1.001001'; # 1.1.1
sub VERSION {
for ($_[1]) {
last unless defined && !ref && int != 1;
die "Major version specified as $_ - this is strictures version 1";
}
# disable this since Foo->VERSION(undef) correctly returns the version
# and that can happen either if our caller passes undef explicitly or
# because the for above autovivified $_[1] - I could make it stop but
# it's pointless since we don't want to blow up if the caller does
# something valid either.
no warnings 'uninitialized';
shift->SUPER::VERSION(@_);
}
sub import {
strict->import;
warnings->import(FATAL => 'all');
my $do_indirect = do {
if (exists $ENV{PERL_STRICTURES_EXTRA}) {
$ENV{PERL_STRICTURES_EXTRA}
} else {
!!($0 =~ /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
and (-e '.git' or -e '.svn'))
}
};
if ($do_indirect) {
if (eval { require indirect; 1 }) {
indirect->unimport(':fatal');
} else {
die "strictures.pm extra testing active but couldn't load indirect.pm
Extra testing is auto-enabled in checkouts only, so if you're the author
of a strictures using module you should 'cpan indirect' but the module
is not required by your users.
Error loading indirect.pm was: $@";
}
}
}
1;
__END__
=head1 NAME
strictures - turn on strict and make all warnings fatal
=head1 SYNOPSIS
use strictures 1;
is equivalent to
use strict;
use warnings FATAL => 'all';
except when called from a file where $0 matches:
/^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
and when either '.git' or '.svn' is present in the current directory (with
the intention of only forcing extra tests on the author side) - or when the
PERL_STRICTURES_EXTRA environment variable is set, in which case
use strictures 1;
is equivalent to
use strict;
use warnings FATAL => 'all';
no indirect 'fatal';
Note that _EXTRA may at some point add even more tests, with only a minor
version increase, but any changes to the effect of 'use strictures' in
normal mode will involve a major version bump.
Be aware: THIS MEANS INDIRECT IS REQUIRED FOR AUTHORS OF STRICTURES USING
CODE - but not by end users thereof.
( run in 0.847 second using v1.01-cache-2.11-cpan-39bf76dae61 )