in reply to directory list
opendir HTMLDIR, $directory_name or die "Can't open $directory_name: $ +!\n"; while (readdir (HTMLDIR)) { push @images, $_) if /\.(png|jpg|gif|tiff)/; }
When you're done, @images will contain a list of the files with the extensions
jpg, png, gif, or tiff (go wild here =)
UPDATE : d'oh! the loop I wrote above doesn't set $_ as it loops through the
directory. Try
instead.foreach ((readdir(HTMLDIR)) { # stuff }
And, while we're at it, you could do
my @files = grep { /png|gif|jpg|tiff$/ } (readdir(DIR));
For one-liner goodness (grep { condition } list grabs everything in list that meets condition)
I daresay these may not be as efficient as Adam's solution above.
Philosophy can be made out of anything -- or less
|
|---|