PDA

View Full Version : globbing files in linux.


Whiteknight
02-28-2004, 06:45 PM
I'm writting a script that works as an Image gallery for a website. what it does is glob() all the files in a directory that have common image extensions(jpg, gif, png etc) and writes out an html page for them all.

that part of my script works perfectly.

what I want my script to do, is to glob together all the sub-folders, in a separate glob.

the idea being that the script will write out links to each sub-folder dynamically. the idea is to keep this script as portable as possible.

any ideas?

jemfinch
02-29-2004, 08:39 AM
You want File::Find, at least to accomplish some of your functionality.

You may need to convert globs to a regular expression; if you read Python's fnmatch.py module, it shows you how to do that.

Jeremy

Whiteknight
03-05-2004, 07:05 PM
i found a relatively nice shortcut to do what i was after:


@all_files = glob("*");
foreach $file (@all_files) {
if( -d $file ){

...


once i test whether its a directory or not, i can do whatever it is i wanted to do with directories in the first place. That, and i dont need to learn a new module!

i win.