Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by Anonymous Monk
on Apr 17, 2021 at 16:15 UTC ( [id://11131409]=note: print w/replies, xml ) Need Help??


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

There is always no warnings 'once';. My personal preference is to use this locally to the error, so that you cam still detect inadvertent cases of this elsewhere in your code.

sub wanted { if ($File::Find::name =~ m%^/path/detection%){ no warnings 'once'; $File::Find::prune = 1; return; } }

Don't worry about adding execution time to your subroutine; this pragma is applied at compile time.

Replies are listed 'Best First'.
Re^2: Why $FIle::Find::prune = 1 returns used only once error
by ikegami (Patriarch) on Apr 19, 2021 at 21:08 UTC

    Or mention it twice.

    sub wanted { if ($File::Find::name =~ m%^/path/detection%){ $File::Find::prune = 1; return; } } require File::Find; $File::Find::name if 0; $File::Find::prune if 0;

    Seeking work! You can reach me at ikegami@adaelis.com

Re^2: Why $FIle::Find::prune = 1 returns used only once error
by h2 (Beadle) on Apr 18, 2021 at 19:43 UTC

    This was a nice one too, I didn't know about the no warnings 'once' to get rid of such warnings on start, that could be in general useful. However, I just realized, after reviewing this thread, that in the end, I used prune = 1 twice once I got the first one debugged, in two blocks, and that made the Perl warning go away of course, since it was used 2 times, but I will note the no warnings 'once' for future reference.

Log In?
Username:
Password:

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

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

    No recent polls found