All pastes #176547 Raw Edit

Tekhne

public text v1 · immutable
#176547 ·published 2006-09-19 19:19 UTC
rendered paste body
# Search for files in a directory
use strict;
use File::Find;
use File::stat;

my @dirs = @ARGV;
my $success = open LOG, ">>logfile";

if ( ! $success ) {
        print "The logfile failed to open";
}

find(\&attrib, @dirs);

sub attrib {
        my $st = stat($File::Find::name) or die "Can't stat $File::Find::name: $!
";
        #find world-writeable files in the directory and subdirectories
        if ($st->mode & 0002) {
                print LOG "$File::Find::name is world-writeable\n";
        }
}

close LOG;