in reply to recursive loop and performace issue in find::file
Ouch! Look at the following:
Never try to remove elements from the array you are currently looping through ... unless you are looking for trouble ;-) (or until you know exactly what you do!) This is probably the reason for your infinite loop.foreach $input(@inputarray) { .... @inputarray = (@newarraypreceding , @newarrayfollowing); ...
Regarding speed: you do a lot of array-copying (splicing and putting together the arrays). Be aware that copying arrays is potentially slow ...
With your program you seem to want to create a list of filenames and check if they are existing in the filesystem. A typical approach would be to use a hash for the list of filenames (use the filename as keys!). For each filename you find in the file-system you would then check if a corresponding entry exists in the hash - and either mark it there or remove it.
If you really need the result in an array (which I doubt), you could create an array out of the hash once at the end.
HTH, Rata
btw.: looking up something in a hash is typically much faster than looking it up in an array...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: recursive loop and performace issue in find::file
by Limbic~Region (Chancellor) on Apr 26, 2011 at 18:51 UTC | |
by Ratazong (Monsignor) on Apr 27, 2011 at 06:58 UTC |