The short answer is save copies of the variables and print those. An easy way to do that is to use local within a block scope:
# ... $res = 0; { local ($number1, $number2)=($number1, $number2); # localize the val +ues $number1 =~ s/\..*//; $number2 =~ s/\..*//; $number1 =~ tr/$,//d; $number2 =~ tr/$,//d; # returns -1, 0 or 1, depending upon comparison $result = $number1 <=> $number2; } # $number1 and $number2 revert to original values when scope is exited # why duplicate this thrice? print "Content-type: text/html\n\n"; print "$number1 is ". ( ($result==0) ? 'equal to' : ($result <0) ? 'less than' : 'greater than' ) ." $number2\n" +;
Update: (see grinder's reply, above)
print "$number1 is ". ('equal to', 'greater than', 'less than')[$result] ." $number2\n";
dmm
You can give a man a fish and feed him for a day ...In reply to Re: How do i print a variable back when it has been altered?
by dmmiller2k
in thread How do i print a variable back when it has been altered?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |