you could also try and open the directory. if it succeeds close it. I used this is a recursive function for mapping drive contents to a logfile.
ie ##Recursive routine to print out all the files & folders under a given
+ root node
sub mapMe
{
#Get the parameter
my ($handle) = shift;
#Open the directory passed to the subroutine
opendir(SPROUT,$handle);
#read the entries
my @entries = readdir(SPROUT);
#Close the directory
closedir(SPROUT);
my $log_entry;
foreach my $i (2..(scalar(@entries)-1))
{
#Format the handle for the next call
my $param_handle = $handle."\\".$entries[$i];
#If its a directory and its not null
if(opendir(TEST,$param_handle) and $entries[$i])
{
#Close the directory
closedir(TEST);
#Strip the handle for log writing purposes
$handle =~ s{\\\\}{\\}g;
#Construct and write the log
$log_entry = "\n".$handle."\\".$entries[$i]."\n";
$log->write($log_entry,length($log_entry));
#recurse the directory
mapMe($param_handle);
}
elsif($entries[$i])
{
#Construct and write the log
$log_entry = "*".$entries[$i]."\n";
$log->write($log_entry,length($log_entry));
}
}
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|