stringify version before comparing, as recommended by Zefram
[p5sagit/Try-Tiny.git] / lib / Try / Tiny.pm
index cf8f1f7..8aa11cc 100644 (file)
@@ -2,7 +2,7 @@ package Try::Tiny;
 use 5.006;
 # ABSTRACT: minimal try/catch with proper preservation of $@
 
-our $VERSION = '0.25';
+our $VERSION = '0.27';
 
 use strict;
 use warnings;
@@ -29,7 +29,7 @@ BEGIN {
   *_HAS_SUBNAME = ($su || $sn) ? sub(){1} : sub(){0};
 }
 
-my @_finally_guards;
+my %_finally_guards;
 
 # Need to prototype as @ not $$ because of the way Perl evaluates the prototype.
 # Keeping it at $$ means you only ever get 1 sub because we need to eval in a list
@@ -78,7 +78,7 @@ sub try (&;@) {
   # this should really be a function scope lexical variable instead of
   # file scope + local but that causes issues with perls < 5.20 due to
   # perl rt#119311
-  local $_finally_guards[0] = [
+  local $_finally_guards{guards} = [
     map { Try::Tiny::ScopeGuard->_new($_) }
     @finally
   ];
@@ -114,7 +114,7 @@ sub try (&;@) {
   # destructor overwrote $@ as the eval was unwinding.
   if ( $failed ) {
     # pass $error to the finally blocks
-    push @$_, $error for @{$_finally_guards[0]};
+    push @$_, $error for @{$_finally_guards{guards}};
 
     # if we got an error, invoke the catch block.
     if ( $catch ) {
@@ -167,7 +167,7 @@ sub finally (&;@) {
   package # hide from PAUSE
     Try::Tiny::ScopeGuard;
 
-  use constant UNSTABLE_DOLLARAT => ($] < '5.013002') ? 1 : 0;
+  use constant UNSTABLE_DOLLARAT => ("$]" < '5.013002') ? 1 : 0;
 
   sub _new {
     shift;
@@ -668,9 +668,4 @@ Or read the source:
 
 L<http://web.archive.org/web/20100305133605/http://nothingmuch.woobling.org/talks/yapc_asia_2009/try_tiny.yml>
 
-=head1 VERSION CONTROL
-
-L<http://github.com/doy/try-tiny/>
-
 =cut
-