Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: Why $FIle::Find::prune = 1 returns used only once error

by jcb (Parson)
on Apr 18, 2021 at 02:28 UTC ( [id://11131419] : note . print w/replies, xml ) Need Help??


in reply to Re^2: Why $FIle::Find::prune = 1 returns used only once error
in thread Why $FIle::Find::prune = 1 returns used only once error

Are you calling import in a BEGIN block? Using use implicitly wraps the require and import into a BEGIN block. If you are waiting to load File::Find until runtime, then the compiler's warning is correct: perl has not seen File::Find yet and your code only mentions File::Find::prune once.

The solution is to always call import in a BEGIN block, so the effects will be visible during the rest of the compilation.

Replies are listed 'Best First'.
Re^4: Why $FIle::Find::prune = 1 returns used only once error
by h2 (Beadle) on Apr 18, 2021 at 19:02 UTC
    Using BEGIN would defeat the entire purpose of making File::Find NOT a dependency at runtime with use File::Find. This program loads many modules during its execution based on conditions and user selected options, and some of those are not in Core Modules, but they are all handled on failure by an error handler telling the user what to do, but in no case should execution halt unless the user has selected an action that does require a Module that may not be in core, or, as with the case of Fedora, has been removed from core. The primary function of this program is to always work for all users in as many cases as possible. It achieves this function with the occasional lapse or forgetting to test, so that's not an issue.