| 1 | # INTERNAL MODULE: Perl 5.8 compatibility for Type::Tiny. | ||
| 2 | |||
| 3 | package Devel::TypeTiny::Perl58Compat; | ||
| 4 | |||
| 5 | use 5.008; | ||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | |||
| 9 | our $AUTHORITY = 'cpan:TOBYINK'; | ||
| 10 | our $VERSION = '2.010001'; | ||
| 11 | |||
| 12 | $VERSION =~ tr/_//d; | ||
| 13 | |||
| 14 | #### re doesn't provide is_regexp in Perl < 5.10 | ||
| 15 | |||
| 16 | eval 'require re'; | ||
| 17 | |||
| 18 | unless ( exists &re::is_regexp ) { | ||
| 19 | require B; | ||
| 20 | *re::is_regexp = sub { | ||
| 21 | eval { B::svref_2object( $_[0] )->MAGIC->TYPE eq 'r' }; | ||
| 22 | }; | ||
| 23 | } | ||
| 24 | |||
| 25 | #### Done! | ||
| 26 | |||
| 27 | 5.8; |