Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^4: Help Changing use into require/import

by computergeek (Novice)
on Mar 08, 2018 at 13:46 UTC ( [id://1210513]=note: print w/replies, xml ) Need Help??


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

So is there a way to load it dynamically?

  • Comment on Re^4: Help Changing use into require/import

Replies are listed 'Best First'.
Re^5: Help Changing use into require/import
by Corion (Patriarch) on Mar 08, 2018 at 13:50 UTC

    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 { ... }, ... );

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-24 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found