in reply to case insensitive file operations

There is no cleaner easy way. In general, the cleanest solution is to change your perl program to deal with case sensitive file systems correctly, and just generally program portably. See also perlport.

Note that a -f does not test for file a exsitence alone -- it also checks if it's a "regular" file (not a directory, device, pipe, etc.) (If you want to test for file exsitence, alone, that would be -e.) Also, note that your regex does not match the way you think it does.

  1. it will match parts of a string. So a file called "test1" will be said to exsit by it if a file called "test10" exsits,
  2. metacharacters are not escaped, so "." will not mean the "." character itself but any character (except newline) when matching filenames.
You could fix these problems with using a regex, but your are probably better off using either lc or uc and eq, e.g.: my($exsits) = grep { lc($file) eq lc($_) } readdir DIR