Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Suppress 'Can't chdir to' warnings for File::Find

by stevieb (Canon)
on Apr 28, 2016 at 17:42 UTC ( [id://1161800]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Suppress 'Can't chdir to' warnings for File::Find
in thread Suppress 'Can't chdir to' warnings for File::Find

In case there are warnings that aren't related to permission issues that show up, instead of disabling warnings, you could stash any warnings File::Find throws into an array, and quickly grep through them for lines not matching any expected warnings to ensure nothing bad is happening in the background without being notified:

use warnings; use strict; use File::Find; my @warnings; { local $SIG{__WARN__} = sub {push @warnings, shift;}; find ({wanted => \&wanted}, '.'); } warn "this warning outside of File::Find, so will print normally\n"; sub wanted { # do stuff } print "caught: $_\n" for @warnings; __END__ this warning outside of File::Find, so will print normally caught: Can't cd to (./) test: Permission denied at find.pl line 10.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-23 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found