homepage Welcome to WebmasterWorld Guest from 54.196.63.93
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
regex match for image files
jwzumwalt

5+ Year Member



 
Msg#: 3803127 posted 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

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 3803127 posted 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

5+ Year Member



 
Msg#: 3803127 posted 5:23 am on Dec 9, 2008 (gmt 0)

That works! :)

I can see now how my logic was wrong... Thansk for teh help!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved