Here's an example:

my @g_filesArray;
my $path = "A_PATH/test/logs/";

# The first parameter is a code ref to a function
find(\&OneLOG, $path);

# Executing sample code for each file
foreach my $file (@g_filesArray)
{
    # Printing the name of the file:
    print $file . "\n";

    # Opening the file:
    open(FHANDLE,"< $file");

    # Closing the file
    close(FHANDLE);

    # Deleting the file
    unlink $file;
}

sub OneLOG()
{
    #It's a good .log file
    /\.log$/i or return;

    # Pushing the file name with the complete path
    push(@g_filesArray,$File::Find::name);
}







-----Original Message-----
From: Subrahmanyam Vadlamani [mailto:[EMAIL PROTECTED]
Sent: 4 août, 2003 15:10
To: perl-unix
Subject: [Perl-unix-users] How to recurse through a directory


Hi:

I would like to recurse through a directory and do
something with the files in the directory (and all
sub-directories).

What is the most efficient way of doing this?  What
are some modules that I could use?

If someone has some example code, I would very much
appreciate it.

thanks

Satish


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to