S.A. Birl wrote:
2 problems, maybe related.

1) My recursive program is generating a "called to early to check
   prototype" error.  Ive Googled for answers but cannot find a solution

That could be because you spelled "too" wrong. In any case, you should have the description of that warning message on your computer in the perldiag.pod file.


perldoc perldiag


And if you change the line "use warnings;" to "use diagnostics;" then perl will print out the complete warning message when your program runs.


perldoc diagnostics


But then why are you trying to reinvent the "traverse a directory tree" wheel when Perl comes with the File::Find module that does that already?



Anyway, your actual problem involves using a subroutine inside that subroutine with a prototype. The easy answer is to remove the prototype.


perldoc perlsub
[snip]
       Because the intent of this feature is primarily to let you define
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       subroutines that work like built-in functions, here are prototypes for
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       some other functions that parse almost exactly like the corresponding
       built-in.


2) When this executes, it traverses 8 directories in F:\\Inetpub\\Develop
   then stops and traverses 8 directories in F:\\Inetpub\\Publish

   I cannot seem to figure out why it's giving up so early when there's
   more than 8 directories in each folder.

Sorry, I cannot see anything obvious and I do not have Windows to test it on.


use strict;
use warnings;

my $indent=0;
my $ERRORS=0;

my $OUTPUT="D:\\Logs\\IIS\\unlock_Read-Only_files.log";

sub OpenDirectory($)
{
    $indent++;

    my $counter=0;
    my $Directory=shift;
    my $FILE;
    my $LongDirectoryName="";



for ($counter=1; $counter < $indent; $counter++) { printf(" "); }

Ick, ick, ick!

      print '  ' x $indent;


    if ( (defined $LongDirectoryName) && ($LongDirectoryName !~ /^$/) )
    {
        $LongDirectoryName=sprintf("%s\\%s", $LongDirectoryName, $Directory);

$LongDirectoryName = join '\\', $LongDirectoryName, $Directory;

Or:

         $LongDirectoryName = "$LongDirectoryName\\$Directory";


    }
    else
    {
        $LongDirectoryName=$Directory;
    }


printf(Loghandle "Opening directory \"%s\": ", $LongDirectoryName);

print Loghandle qq(Opening directory "$LongDirectoryName": );


if ( opendir(DIRhandle, "$LongDirectoryName") )

if ( opendir DIRhandle, $LongDirectoryName )

perldoc -q "What's wrong with always quoting"


    {
        printf(Loghandle "success\n");

print Loghandle "success\n";


        while ( defined ($FILE = readdir(DIRhandle)) )
        {
            for ($counter=0; $counter < $indent; $counter++) { printf(Loghandle "  
"); }

print Loghandle ' ' x $indent;


            if ($FILE =~ /\.\.?$/)
            {
                printf(Loghandle "skipping \"%s\"\n", $FILE);

print Loghandle qq(skipping "$FILE"\n);


            }
            else
            {
                if    (-f "$LongDirectoryName\\$FILE")
                {
                    #printf(Loghandle "\"%s\" is a file.\n", $FILE);
                    if ( system("attrib -R $LongDirectoryName\\$FILE") )

Are you sure that you are using system() correctly? Is there not a built-in function or module that could do the same thing without using system()?



                    {
                        for ($counter=0; $counter < $indent; $counter++) { 
printf(Loghandle "  "); }
                        printf(Loghandle "FAILED: file attrib    $!\n");

print Loghandle ' ' x $indent, "FAILED: file attrib $!\n";


Why do you think that there will be anything useful in $!? Have you read the documentation for the system() function?

perldoc -f system


                    }

                }
                elsif (-d "$LongDirectoryName\\$FILE")
                {
                    #printf(Loghandle "\"%s\" is a directory.\n", $FILE);
                    if ( system("attrib -R $LongDirectoryName\\$FILE") )
                    {
                        for ($counter=0; $counter < $indent; $counter++) { 
printf(Loghandle "  "); }
                        printf(Loghandle "FAILED: folder attrib  $!\n");

print Loghandle ' ' x $indent, "FAILED: folder attrib $!\n";



                    }

                    OpenDirectory("$LongDirectoryName\\$FILE");
                }
                else
                {
                    printf(Loghandle "\"%s\" is an unknown.\n", $FILE);

print Loghandle qq("$FILE" is an unknown.\n);


                }
            }

printf("Analyzed: \"%s\\%s\"\n", $LongDirectoryName, $FILE);

print qq(Analyzed: "$LongDirectoryName\\$FILE"\n);


        }
    }
    else
    {
        printf(Loghandle "FAILED: $!\n");

print Loghandle "FAILED: $!\n";


    }

    closedir(DIRhandle);
    $indent--;
}



if (! open(Loghandle, ">$OUTPUT") )
{
    die "Could not open \"$OUTPUT\" for writing: $!";
}

OpenDirectory("F:\\Inetpub\\Develop");
OpenDirectory("F:\\Inetpub\\Publish");


John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to