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


in reply to Re^4: Help Changing use into require/import
in thread Help Changing use into require/import

Just use require Capture::Tiny at runtime, like you already did in your code.

The thing you are missing is that Perl doesn't know that capture should become a function. You can either try to predeclare capture as subroutine to tell that you expect a capture subroutine:

sub capture(&@); ... require Capture::Tiny; Capture::Tiny->import('capture'); capture { } ...;

Or go the more explicit route of calling capture in a way that doesn't need parser gymnastics:

capture( sub { ... }, ... );