[wplug] case utility

Gary Morrow gary.morrow at ansys.com
Mon Apr 4 17:15:57 EDT 2005


Teodorski, Christopher wrote:
> Here is my attempt at an explanation of the particular issue at hand:
> 
> A web application was written for Windows.  Thus allowing said
> developers to play fast and loose with case, i.e. the file name is
> myimage.jpg -- however in the code, it is referred to as MyImage.jpg and
> myImage.jpg and mYiMage.jpg.    This works fine in Windows because as we
> all know Windows is case insensitive (except when it isn't).  
> 
> However, this application is looking for a new home on a *nix box and
> features many 404's now because of the above mentioned case issue when
> run on *nix.
> 
> The question is:  Is there a good way to grab a filename from a
> directory -- and match it regardless of case within all files in the
> directory and if a match is found replace it with the proper case. 
> 
> It sounds to me like a job for Perl -- but I'm a Perl noob and it'd take
> me some serious time to get my head wrapped around this (although I'm
> going to give it the old college try).
> 
> 

To compare them I would first downcase both names.

In Perl:

opendir(HERE,"/home/gwm/work");
@files = readdir HERE;
close HERE;
$reqName = $ARGV[0];

($down1 = $reqName) =~ tr/A-Z/a-z/;

LOCAL:
foreach $localName ( @files ) {

	($down2 = $localName) =~ tr/A-Z/a-z/;

	if ( $down1 eq $down2 ) {
		print "$localName\n";
		last LOCAL;
	}

}

Gary

> 
> 
> 
> -----Original Message-----
> From: wplug-bounces+christopher.teodorski=ddiworld.com at wplug.org
> [mailto:wplug-bounces+christopher.teodorski=ddiworld.com at wplug.org] On
> Behalf Of Jonathan Billings
> Sent: Sunday, April 03, 2005 10:18 PM
> To: General user list
> Subject: Re: [wplug] case utility
> 
> On Apr 3, 2005 9:02 PM, Freisleben, Kayln
> <Kayln.Freisleben at ddiworld.com> wrote:
> 
>>Does anyone know of a utility that will rip through a program and
> 
> match 
> 
>>the case of the program call with the file being called?
> 
> 
> I'm sorry, what you have said doesn't make any sense.  Could you
> describe what you want to do with a bit more detail?  Maybe give an
> example of what you'd expect?
> 


-- 
Gary Morrow
UNIX Systems Engineering and CASE Tools.
Ansys Inc.
gary.morrow at ansys.com
Phone: 724-514-2978
Fax: 724.514.3117
-------------------------------------------------------------
The information transmitted is intended only for the person or entity to 
which it is addressed and may contain confidential and/or privileged 
material. Any review, retransmission, dissemination or other use of, or 
taking of any action in reliance upon, this information by persons or 
entities other than the intended recipient is prohibited. If you 
received this in error, please contact the sender and delete the 
material from any computer.




More information about the wplug mailing list