| regex match for image files
|
jwzumwalt

msg:3803129 | 3:11 am on Dec 9, 2008 (gmt 0) | I am writing a perl program where I would like to separate dir names, and image files. The bit of code listed below works great for getting the dir names. Now I would like to separate files if they are images. I have struggled for two days and have not got anything to work. As a test case I am experimenting with an icon file name. Thanks for the help - JZ opendir (DIR, "..$request_dir"); chdir "..$request_dir"; foreach (readdir DIR) { if (-d) { push(@dir_list, $_); } elsif ($_ =~ /(.ico$)(.png$)/i) { <--- separate out image files push(@image_list, $_); } else { push(@file_list, $_); } } closedir DIR;
|
phranque

msg:3803134 | 3:19 am on Dec 9, 2008 (gmt 0) | maybe this will work better: } elsif ($_ =~ /\.(ico¦png)$/i) { <--- separate out image files (replacing the broken pipe with a solid pipe of course)
|
jwzumwalt

msg:3803200 | 5:23 am on Dec 9, 2008 (gmt 0) | That works! :) I can see now how my logic was wrong... Thansk for teh help!
|
|
|