I've been chasing my tail over something extremely similar myself of late - to the point of drafting a SoPW node. Ovid has, unknown to him 'til now, saved me the trouble of the posting and provided the clarity/insight I was seeking...
My algorithm did the simplest test (eval { require ...}) first, going on to test for a local file scoped package after that - so a non-existent package always exists if a test is made for the existence of the stash.
It never even occurred to me that, as Ovid points out, the require causes vivification of a stash for the package - whether or not it exists ... doh !!!
Many thanx again Ovid.
.oO(Wonder whether my sig should be changed to read: "A user level that overstates my experience by an order of magnitude" ?)
Update:
Nearly, but not quite - some more extensive testing (appears to) show that a stash is always created - but would appear to be empty i.e. no keys, if the package is non-existent. So whereas require creates the stash and (sometimes) partially populates it, the test for the stash also appears to create a stash - but seemingly always empty ... or more accurately, an existent package always has the standard packages & classes as its keys.
Any road up, it's close enough for jazz at this joint :D))
In reply to Re: How Can I Know If a Package is "Real"?
by Bloodnok
in thread How Can I Know If a Package is "Real"?
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |