[CODE] use Cwd; use warnings; use strict; checkdatabase(); sub usage { print "Usage: perl $0 file_to_find\n"; exit; } sub checkdatabase { my $dbfile = 'c:/windows/locate.db'; open(my $fh,$dbfile) or createdatabase(); close($fh); my $checkage = lastmodif($dbfile); if($checkage > 10) { print "warning: database is more than 10 days old\n"; my $ans; while($ans ne "y" || $ans ne "n") { print "Do you want to update? [y/n]: "; chomp(my $ans = ); } if($ans eq "y") { unlink("c:/windows/locate.db"); createdatabase(); } } my $file = @ARGV or usage(); filesearch($file); } sub filesearch { my $file = shift; my $dbfile = 'c:/windows/locate.db'; open(my $fh,$dbfile) or createdatabase(); while(<$fh>) { if($_ =~ $file) { print "$_\n"; } } close $fh; exit; } sub lastmodif { my $file = shift; my $mtime = (stat($file))[9]; my $secs = time - $mtime; my $days = int($secs / 86400); return $days; } sub createdatabase { scandir("/"); print "Database created/updated\nexiting\n"; exit; } sub scandir { my $curdir = shift; my $startdir = &cwd; chdir($curdir) or die $!; opendir(my $dir,".") or die $!; my @files = readdir($dir) or die $!; closedir($dir); open(my $fh,'>>',"c:/windows/locate.db") or die $!; foreach my $file (@files) { next if ($file eq "."); next if ($file eq ".."); if(-d $file) { scandir($file); next; } print $fh "$startdir/$curdir/$file\n"; } close($fh); chdir($startdir) or die $!; } [/CODE] [Unwanted output] C://C://a C://C://a.txt C://C://acrack.pl C://C://asdf.pl C://C://AUTOEXEC.BAT C://C://boot.ini C://C://ciasteczka.txt C://C://ciscos.c C://C://CONFIG.SYS C://C://DebugTrace-RockallDLL.log C://C://djpeg.exe C://C://Endocing.txt C://C://error.txt C://C://faks_VAZNO!@#%@$#.txt C://C://FLV2Video_Setup_r44744.exe C://C://get_video.flv C://C://gocr.exe C://C://IO.SYS C://C://item1771.jpg C://C://locate.pl C://C://Matrix-sida.jpg C://C://MSDOS.SYS C://C://NTDETECT.COM C://C://ntldr C://C://pass.txt C://C://PDOXUSRS.NET C://C://RivaEncoderSetup.exe C://C://sambal.c C://C://showMessagePane.php [/Unwanted output] sub scandir() wont finish, it always stops when it needs to scan the very root directory and it exits with error: Invalid argument at locate.pl line 57.