From 774f4f10836a4e4fa82468d11d0e59730c431399 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 2 May 2011 16:12:33 -0500 Subject: better argument checking for ->new --- lib/Package/Stash/PP.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/Package/Stash/PP.pm') diff --git a/lib/Package/Stash/PP.pm b/lib/Package/Stash/PP.pm index 9004c5d..fdb8da9 100644 --- a/lib/Package/Stash/PP.pm +++ b/lib/Package/Stash/PP.pm @@ -26,6 +26,17 @@ This is a backend for L implemented in pure perl, for those with sub new { my $class = shift; my ($package) = @_; + + 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; -- cgit v1.2.3-54-g00ecf