Out of curiosity, is there a big performance increase using a recursive
algorithm like the one described versus an algorithm like below?  (This is
part of something I was working on a while ago, and I wasn't using strict or
-w at the time, I'm still trying to train myself on that one :P)

@dirs = @ARGV; #Must be full path!
foreach $dir(@dirs){
    print "READING $dir...\n\n";
    opendir(DIR,$dir) || warn "Could not open $dir!";
    @dir = readdir(DIR);
    closedir(DIR);
    foreach $file(@dir){
        unless($file eq "." || $file eq ".."){
            if(-e "$dir\\$file" && -d "$dir\\$file"){
                print "DIR -- $dir\\$file\n";      #Do Something
                push @dirs,"$dir\\$file";
            }elsif(-e "$dir\\$file"){
                print "FIL -- $dir\\$file\n";      #Do Something
            }else{
                print "Error\: No such file -- $dir\\$file!\n";
            }
        }
    }
    undef @dir;
}


-----Original Message-----
From: Dhiraj P Nilange
To: [EMAIL PROTECTED]
Sent: 1/26/02 1:35 AM
Subject: urgent: How to declare FILE HANDLE locally?


Hello 
I have a very urgent and important question.
How do I declare or use file handle locally
in PERL? I am writing a recursive sub to 
locate files in subdirectories. This sub
calls itself when it finds directory ; if
there are directory under this directory
again then again it calls itself. The problem
is that as I am unable to declare filehandle
(I am using "readdir" and "opendir" builtin
functions) ; in subsequent calls to the 
sub ; the HANDLE refers to the firstmost
opened directory.

if I used "my" keyword for this purpose then
perl gives error.

So how to define file handle locally? its my
urgent need!

Thanks
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------------------
This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to