in reply to Re^2: Order of 'use' statement in Data::Dumper
in thread Order of 'use' statement in Data::Dumper

That's true (and something I didn't know psini++), but I think the op was expecting
use Module;
to be equivalent with
BEGIN{require Module;}
, which it is not.

Replies are listed 'Best First'.
Re^4: Order of 'use' statement in Data::Dumper
by psini (Deacon) on Jul 16, 2009 at 16:52 UTC

    Sorry but, in this example at least, it is equivalent.

    Both use and BEGIN are executed at compile time, but only when the compiler reach their position. So:

    use strict; use warnings; my %test_hash = ( a => { b=> 'c' } ); print Dumper %test_hash; BEGIN{require Data::Dumper; Data::Dumper->import}

    gives the same error as above where

    use strict; use warnings; my %test_hash = ( a => { b=> 'c' } ); print Dumper(%test_hash); BEGIN{require Data::Dumper; Data::Dumper->import}

    works, for exactly the same reason.

    Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

      You are right -- I stand corrected.