in reply to Cant locate DBI in @INC

This post adds to almut's post in case you want more details on compilation and execution order. If you don't, then skip this post.

use Module;
is the same as
BEGIN { require Module; Module->import(); }

(In fact, in existing versions of Perl, the parser can't tell the difference and that's the source of a bug unrelated to this post.)

BEGIN blocks are execute as soon as they are compiled, so

push (@INC, "D:\\Perl\\site\\lib"); use DBI;
is executed as follows:
  1. push (@INC, "D:\\Perl\\site\\lib"); is compiled.
  2. require DBI; is compiled.
  3. DBI->import(); is compiled.
  4. require DBI; is executed (by virtue of being in a BEGIN block).
  5. DBI->import(); is executed (by virtue of being in a BEGIN block).
  6. The rest of the program is compiled.
  7. The compilation phase ends and the execution phase begins.
  8. push (@INC, "D:\\Perl\\site\\lib"); is executed.
  9. The rest of the program is executed.

As you can see, the modification of @INC happens much much too late.