Try removing the newline at the end of your question with a call to chomp.


else{
   for (my $i=1; $i<=$#qk+1;$i++){
chomp ($Question_hash{$qk[$i-1]});
print In1
"Question"."$i".":factor$Question_hash{$qk[$i-1]}=$Answer_hash{$ak[$i-1]}\n";
}


>Here is a subroutine that prints strings to a file. I want the routine
>to write strings to the file in the format
>Question1:factor(x^2+4*x+3)=(x+3)*(x+1).
>However, what is written to file is
>Question1:factor(x^2+4*x+3)
>=(x+3)*(x+1), that is,
>a newline before the = sign. Is there some way of inhibiting this
>behavior?
>Thanks,
>Dick Fell
>
>
>
>sub write_questions_and_correct_answers_to_file{
>open In1, ">/home/rfell/tutoring/beaven/webproject/tmp/factor_answers"
>or die "Cannot open factor_answers: $!";
>my @qk; # temporary array to hold sorted questions keys
>my @ak; # temporary array to hold sorted answer keys
>my $qk; # temp variable to hold element of @qk
>my $ak; # temp variable to hold element of @ak
>@qk=sort(keys %Question_hash);
>@ak=sort(keys %Answer_hash);
>if ($#qk!=$#ak){
>print "lengths of question hash and answer hash are not equal.\n";
>exit();
>}
>else{
>   for (my $i=1; $i<=$#qk+1;$i++){
>print In1
>"Question"."$i".":factor$Question_hash{$qk[$i-1]}=$Answer_hash{$ak[$i-1]}\n";
>}
>}
>close In1;
>}
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


-- 



________________________________________________

Hans E. E. Holtan
Graduate Student
UC Berkeley-Department of Plant and Microbial Biology
Plant Gene Expression Center
800 Buchanan Street
Albany, California 94710
U. S. A.
Phone: (510) 559-5922
FAX: (510) 559-6089
[EMAIL PROTECTED]
_________________________________________________

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to