CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
check file handles, and be case insensetive...

 



$0.05$
Novice

Jul 16, 2002, 10:24 PM

Post #1 of 4 (2132 views)
check file handles, and be case insensetive... Can't Post

how do i check a file handle (ie .txt) but make it so that its case insensetive, so .TXT is equivalent to .txt, and .tXt etc...


davorg
Thaumaturge / Moderator

Jul 17, 2002, 1:44 AM

Post #2 of 4 (2130 views)
Re: [$0.05$] check file handles, and be case insensetive... [In reply to] Can't Post

What do you mean by "check a file handle"? What you you actually want to do?

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


$0.05$
Novice

Jul 17, 2002, 8:38 AM

Post #3 of 4 (2128 views)
Re: [davorg] check file handles, and be case insensetive... [In reply to] Can't Post

well, what i want to do, is check a bunch of files in a directory, and be sure that their picture files. if their not picture files delete them. i want to be sure that its either a .jpg, .gif, .bmp, .png. But not all the file handles are lower case, some of them are .GIF, .JPG etc.

how do i check to be sure that all the files in a certain directory are picture files.


davorg
Thaumaturge / Moderator

Jul 17, 2002, 8:56 AM

Post #4 of 4 (2127 views)
Re: [$0.05$] check file handles, and be case insensetive... [In reply to] Can't Post

Use /i on the regex you use to check the files. Something like this (untested).

Code
foreach (<$dir/*>) { 
if (/\.(gif|jpg|bmp|png)$/i) {
print "$_ is an image\n";
} else {
print "$_ is not an image\n";
}
}


--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives