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: Intermediate:
case insensitive -e test

 



kovlensky
New User

Dec 8, 2008, 2:47 PM

Post #1 of 4 (295 views)
case insensitive -e test Can't Post

Imagine that I've got file path which exists. Like "/home/user/aaa.txt". The issue is that is exists - but with broken case sensitivity. It means that it can arrive like "/HOme/uSer/aaA.Txt". Now the question is - how to sort its case sensitiveness, for example to get "/AAA.txt" as argument, verify that is doesn't exists, but "/aaa.txt" does, so correct the path and display the corrected one? That's more logic question that perl one, but I do need to do that in perl.

Damn windows users, they don't care about lettercase at all...


winfinit
User

Dec 8, 2008, 3:11 PM

Post #2 of 4 (291 views)
Re: [kovlensky] case insensitive -e test [In reply to] Can't Post

i think what you are looking for is /i in regex, you can read content of your dir via readdir and then match it against the entries in the file that contains names and write each matched entry to a new file. that way you will get a list of correct names in one place.


KevinR
Veteran


Dec 8, 2008, 3:11 PM

Post #3 of 4 (291 views)
Re: [kovlensky] case insensitive -e test [In reply to] Can't Post

if all the files to be checked are always lower case you can convert the argument to lower case using lc()


Code
$string = lc ($string); 
if (-e $string) {
....
}


but if the file on the server can be mixed case in any order this will prove to be a difficult task and could find files you dont want it to since AAA.txt and aaa.txt would be two different files on a case sensitive OS.
-------------------------------------------------


kovlensky
New User

Dec 8, 2008, 3:29 PM

Post #4 of 4 (289 views)
Re: case insensitive -e test [In reply to] Can't Post

Winfinit - it is not guaranteed that dirs have correct lettercase. I can guarantee for leading slash only.Yes, I know that I can go directory by directory till I reach the last file, but there must be an easy way. I can find few really hard ones, but perl is for making life easy, right?:)

KevinR - it is not always lowercase. And there will always be one file possible only - full directory tree is rsynced from windows.

 
 


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

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