in reply to perl find module

# findmaster.pl # usage: findmaster.pl <path> # find files ending with '.master' use strict; use File::Find; if ($ARGV[0] eq "") { $ARGV[0]="."; } find (sub { if ($File::Find::name =~ /\.master$/i) { print "Found $File::Find::name\n"; } }, @ARGV);

Replies are listed 'Best First'.
Re^2: perl find module
by scorpio17 (Canon) on Nov 09, 2009 at 16:38 UTC
    The variable $_ will contain the current file name.
    The variable $File::Find::dir will contain the current path.
    The variable $File::Find::file is the file name including the the path.
    So maybe you want to change the print line to this:
    print "Found file $_ in directory $File::Find::dir\n";
Re^2: perl find module
by RajNaidu (Novice) on Oct 30, 2009 at 09:34 UTC

    Hi, Thanks for the reply. I am trying to fit in the below code, to search a file with the extension .master. Here how do i specify the directory which contains the master file.

    use strict; use File::Find; if ($ARGV[0] eq "") { $ARGV[0]="."; } find (sub { if ($File::Find::name =~ /\.master$/i) { print "Found $File::Find::name\n"; } }, @ARGV);