one more scalar type
[gitmo/Package-Stash.git] / lib / Package / Stash / PP.pm
index 4856d14..76129ed 100644 (file)
@@ -26,7 +26,17 @@ This is a backend for L<Package::Stash> implemented in pure perl, for those with
 sub new {
     my $class = shift;
     my ($package) = @_;
-    my $namespace;
+
+    if (!defined($package) || (ref($package) && ref($package) ne 'HASH')) {
+        confess "Package::Stash->new must be passed the name of the "
+              . "package to access";
+    }
+    elsif (ref($package) eq 'HASH') {
+        confess "The pure perl implementation of Package::Stash doesn't "
+              . "currently support anonymous stashes. You should install "
+              . "Package::Stash::XS";
+    }
+
     return bless {
         'package' => $package,
     }, $class;
@@ -95,7 +105,7 @@ sub _valid_for_type {
     }
     else {
         my $ref = reftype($value);
-        return !defined($ref) || $ref eq 'SCALAR' || $ref eq 'REF' || $ref eq 'LVALUE';
+        return !defined($ref) || $ref eq 'SCALAR' || $ref eq 'REF' || $ref eq 'LVALUE' || $ref eq 'REGEXP' || $ref eq 'VSTRING';
     }
 }