Thanks Vinai, For the code and the explanations.
Ken > -----Original Message----- > From: vinai AR [mailto:[EMAIL PROTECTED]] > Sent: Thursday, October 17, 2002 1:54 PM > To: Ken Cole; [EMAIL PROTECTED] > Subject: RE: Getting A File Name > > > I think this script will help u. > Assume that u r in the directory where u have these three > files.(If not > use chdir and move to that directory). > > @file_List = <fred.*> > > On executing the above statement @file_List will have all the three > files fred.*. > > map {$_ =~ s/fred.//} @file_List > > The above statement removes the "fred." from each file name and the > @file_List array will only have the extension part of each file. > > My $ext = 0; > foreach $val (@extension) > { > $ext = $val if($val > $ext); > } > > Now the variable $ext will have the highest suffix value. > > We can generate the file name with the below statement. > $file_Name = "fred.$ext"; > > The full code is below > > @file_List = <fred.*>; > map ($_ =~ s/fred.//gi, @file_List); > my $ext = 0; > foreach $val (@file_List) > { > $ext = $val if($val > $ext); > } > $file_Name = "fred.$ext"; > print "$file_Name\n"; > > Rgds, > vinai > -----Original Message----- > From: Ken Cole [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, October 16, 2002 7:44 AM > To: [EMAIL PROTECTED] > Subject: Getting A File Name > > > Hi, > > I have a directory in which there are files such as: > > fred.1 > fred.2 > fred.3 > > The suffix increases and older files get deleted so there are always 3 > fred.* files in the directory at any one time. > > I need to get the name of the file with the highest suffix so I can go > and do some other stuff with it. > > I have tried lots of different things but to no significant outcome. > > Any suggestions? > > Thanks > > Ken > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]