Status update on reply-pls to Previous Status

Need to get the previous value of the ticket before updating the ticket.
For Ex.
If ticket is in open state then it is moved to reply-pls, so know whenever somebody will reply on the ticket it should go back to open state(i.e the status before reply-pls) I have written a custom script for that
and $self->TicketObj->Status->Oldvalue is the piece of code I’m using to get the value.
But after replying agian it goes back to reply-pls.
So if somebody can help me with the code