protoplasm wrote:
On Apr 5, 7:20 am, [EMAIL PROTECTED] (John W. Krahn) wrote:
WARNINGS
If you run your program with the "-w" switch, or if you use the
"warnings" pragma, File::Find will report warnings for several
weird situations. You can disable these warnings by putting the
statement
no warnings 'File::Find';
in the appropriate scope. See perllexwarn for more info about
lexical warnings.
Here is the solution to my problem ... the use of the 'open' and
'close' functions:
Did you even *try* using "no warnings 'File::Find';"?
#! /opt/local/bin/perl -w
eval 'exec /opt/local/bin/perl -S $0 ${1+"$@"}'
if 0; #$running_under_some_shell
use strict;
use File::Find ();
# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;
sub wanted;
my @libdir = ( "/usr/lib", "/usr/lib64", "/usr/local/lib", "/opt", "/
lib", "/lib64",);
open(OLDERR, ">&STDERR");
open(STDERR, ">/dev/null") or die "Can't redirect stderr: $!";
# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, @libdir);
exit;
close(STDERR) or die "Can't close STDERR: $!";
open( STDERR, ">&OLDERR") or die "Can't restore stderr: $!";
close(OLDERR) or die "Can't close OLRDERR: $!";
Those close() and open() statements will not run because the program
exit()s first.
sub wanted {
/^libaest\.dylib\z/s &&
print("$name\n");
}
"Your program" was actually generated by the 'find2perl' program and as
such has a lot of stuff in there that you don't need. It could be
simplified to:
#!/opt/local/bin/perl
use warnings;
use strict;
use File::Find;
no warnings 'File::Find';
find sub {
print "$File::Find::name\n" if $_ eq 'libaest.dylib';
}, qw{ /usr/lib /usr/lib64 /usr/local/lib /opt /lib /lib64 };
__END__
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/