RE: How to find same filename in subdirectory
From: Lktee (lktee_at_bantex.com.my)
Date: 05/26/04
- Next message: John W. Krahn: "Re: Detecting the Country and other information of a IP address"
- Previous message: Marcos Rebelo: "RE: Question of memory management in Perl"
- Next in thread: John W. Krahn: "Re: How to find same filename in subdirectory"
- Reply: John W. Krahn: "Re: How to find same filename in subdirectory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: 'Jan Eden' <lists@janeden.org> Date: Wed, 26 May 2004 17:24:08 +0800
Hi, now I design another way.
First I request user enter the directory want to search first, if the
directory exist in the system, script will search the entire directory. If
the filename is same will display out, else no result will return. If
directory not exist will request user try another directory.
So, the script like below:
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
find ( \&callback, "/$target");
my $target;
while (1) {
print "what directory want search?";
$target = <STDIN>
chmod $target;
if (-d $target) {
print "Yes, target is a directory.\n";
next;
}
else{
print "No, $target not a directory.\n";
sub callback{
print $File::Find::name, "\n" if $File::Find::name =~
/File1$/;
}
May I know any wrong in my coding? Because I cannot run the script. Any idea
about this?
- Next message: John W. Krahn: "Re: Detecting the Country and other information of a IP address"
- Previous message: Marcos Rebelo: "RE: Question of memory management in Perl"
- Next in thread: John W. Krahn: "Re: How to find same filename in subdirectory"
- Reply: John W. Krahn: "Re: How to find same filename in subdirectory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|