in reply to A feature of use

Replies are listed 'Best First'.
Re^2: A feature of use
by bart (Canon) on Aug 21, 2008 at 09:22 UTC
Re^2: A feature of use
by ambrus (Abbot) on Aug 21, 2008 at 07:36 UTC

    It certainly seems so, we can even verify this like this.

    perl -we 'use IO::Handle; { package IO::Handle; sub import { warn "imp +ort called on handle $_[0]"; } } if (0) { open strict; } BEGIN { warn + "about to use strict"; } use strict; BEGIN { warn "after use strict" +; } use warnings;'

    However, I don't understand why this happens even before the open is called at all. I originally wrote the snippet with open in a BEGIN, because I thought that was the only way to trigger this. In fact, as open $foo, ... should autovivify a new glob with filehandle each time it's executed, I don't really know why open strict should do anything in compile time.

    Indeed, notice how my $h = *strict; open $h; triggers the feature if it's ran in a BEGIN block before use strict;, but not if it's just compiled before it.