in reply to searching several files for a string at one time

this is the code I've been using

@files = <*>; foreach $file (@files) { print $file . "\n"; }

You can include any path in your filesystem between the <> marks. For example, say your web site is in the /var/www/htdocs/ directory and you want a list of all the files:

@files = </var/www/htdocs/*>;

Or if you just want a list of the files with the extension .html:

 @files = </var/www/htdocs/*.html>;

however, where it says I can include any path, it doesn't work as it still only lists the directory that the .pl file is in Sorry for notposting the code :)

Replies are listed 'Best First'.
Re^2: searching several files for a string at one time
by Corion (Patriarch) on May 06, 2010 at 10:12 UTC

    I forgot a very simple function that you might want to use to replace <...>: File::Glob::bsd_glob - it works just like <...> but it accepts the directory to glob as a parameter and understands whitespace in directory names.