in reply to Searching Sub Dir for Files

You can use File::Find to do the traversing for you -- it will do exactly what you want (recursively find *.sas files and do something to them).
As to modifying your code, you would need to toss what you have into a function, and then call itself (recursion) on any subdirs found.. This is all the work that File::Find will do automagically for you.

Replies are listed 'Best First'.
Re^2: Searching Sub Dir for Files
by Fuism (Beadle) on Jun 01, 2005 at 19:02 UTC
    File:Find is a module. Im running this on a Unix server and do not have SA permissions and do not want to install any modules on the server. I basically have 2 options 1) Install the module on my pc and run it from my pc to do this (Would this work if I have to telnet into the Unix box)? 2) Write my script to do what File:Find would do? Any suggestions? Thanks again everyone... Fue
      Is installing it locally (like in /home/yourname/local) an option?
      1) is not an option--if it's running on the server, it can't read your modules from your pc.
      2) you can, but it will take time, and not be as robust as the hardened and proven File::Find module.

      You can always look at File::Find's source, but i would strongly recommend using the module itself (are you sure it's not installed already?). If you're going to write it yourself, i'm sure you can find a recursion example of doing just this...

      A workaround would be to use unix tools .. construct a commandline w/somthing like (i'm sure you'll want to tweak the egrep settings):
      my $cmd = 'find /some/path -name \*.sas | egrep -l ' . "'(" . join(' +|',@words) . ")'";
        Well our Unix box has the bare minimum when it comes to perl... no modules installed. I cant install it on the unix box. As for #1, lets say if I install it on my PC using ppm, and use the Telnet Module to telnet over and use File:Find to search directories, would that work? Pao