i open 3 files on a unix machine (ABC.txt, abc.txt, AbC.txt) and for some reason, they all open different files, not the same one. Is there a way to make all 3 files be the same? I thought about lowercasing abc to a variable and then opening it, but does anyone have another suggestion?

That's because *nix is case sensitive, so ABC.txt is not the same file as aBc.txt. The easiest way I can think of to perform a case insensitive search of existing files of varying case is like this:

Code

my $searchfor = qr/abc/i; # change abc to whatever

my @files = grep {-T} glob '/home/yourdomain/data/dirtosearch/*';

for (@files){ print "$_\n" if /$searchfor/; }

In a nutshell, the above is grabbing the entire contents of the directory you're searching and tossing it in @files then printing the filename only if it matches the search pattern regardless of case.

Assuming you have a match, you can do whatever you need to with the file -- open it, write to it, delete it. You have the full path to the file and the filename as it appears on the server, regardless of the case of the filename.

I'm sure there's a better (and shorter) way to do this, but this is the best I can do at this wee hour