open(IN,'STNAMES.DAT') or die "Can't open STNAMES.DAT: $!"; # open student consolidated names open(OUT,'>results') or die "Can't create results: $!\n"; # result file open output
$counter = 1; # Use a better variable name than c. What does c stand for?? I'm assuming counter foreach (<IN>) { # Now READ the contents of the IN filehandle, one line at a time # This next line looks like it could trip you up. Maybe a regex would be better. Can you provide some sample lines from the input file?? $foo=substr($_,0,26); # strip out only the student last name and first name. # Next, you are not performing a loop here, but are using the while operator. You would be better just checking for existence of the value. if (exists($student{$foo}) { # while(exists($student{$foo})){ # if the students is used already $foo= "$_$counter"; # add the numer to it # What are you trying to achieve here?? $_=$foo,substr($_,27,20); # add the remainder of the file back on to input string $c++; # increment the number } Sorry for jumping in halfway through this thread. Could you post *all* the code you have so far, a sample of the input data and detail exactly what you are trying to do? Maybe then we can help some more. Thanks John -----Original Message----- From: Susan Aurand [mailto:[EMAIL PROTECTED]] Sent: 15 February 2002 15:14 To: [EMAIL PROTECTED] Subject: Re: Help me out I took your advice and added the following code to my source code. I want to print the students name to the result file regardless if I add a number on the end of the student name or not. I have tried putting the PRINT O at different location in this code. I can not get it to print to the result file. WHY and HELP!! Thank You Susan open(I,'STNAMES.DAT') or die$!; # open student consolidated names open(O,'>results') or die"results: $!\n"; # result file open output $c=1; $foo=substr($_,0,26); # strip out only the student last name and first name. while(exists($student{$foo})){ # if the students is used already $foo= "$_$c"; # add the numer to it $_=$foo,substr($_,27,20); # add the remainder of the file back on to input string $c++; # increment the number } > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------Confidentiality--------------------------. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]