use A; test1(); sub test1 { ... } print 'i'; use B; print 'j'; sub test2 { ... } BEGIN { print 'begin'; }