http://www.perlmonks.org?node_id=1210645


in reply to Help Changing use into require/import

capture { system qq[ echo Hello, World | cat ]; }

Can't call method "capture" without a package or object reference

Hypothesis (untested): if you do Capture::Tiny::->import("capture"); at BEGIN time, like use does, Perl knows the prototype of the capture function (which contains & and makes it accept blocks which are really anonymous subroutines without sub keyword). If you do the import at runtime, the subroutine is still imported (you can call it without fully qualifying Capture::Tiny::capture), but it's too late for Perl parser to change its understanding of your code: instead of capture(sub{...}), it sees {...}->capture and fails.