in reply to Compile time action of require in 5.10.1??

This will give you part of the answer:

$ perl -E'if (0) { require Foo::Bar } say for keys %Foo::' Bar::

A require PackageName statement creates an empty stash for the package at compile time, even if the statement never gets executed.

The next part of the answer is in gv.c, the Perl_newIO function. Part of what this function does is to check whether the FileHandle package exists (and it does this by checking whether the stash exists!) and if not, aliases it to IO::Handle.

It's all pretty dumb. The situation was improved in 5.12, and as of 5.14 works sanely.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Replies are listed 'Best First'.
Re^2: Compile time action of require in 5.10.1??
by djerius (Beadle) on Feb 06, 2014 at 22:16 UTC
    Thanks for the explanation!

    I'd seen the code in Perl_newIO but didn't understand how it got triggered. Now it all makes sense.

    Well, that was 5 hours of my life gone trying to figure out why my tests using Test::Trap in systemsafe mode were silently dieing on 5.10.1. All because there was a use FileHandle::Fmode in a module far, far away.