Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Help Changing use into require/import

by Anonymous Monk
on Mar 11, 2018 at 09:36 UTC ( #1210645=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1210645]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2021-04-17 17:02 GMT
Find Nodes?
    Voting Booth?

    No recent polls found