.can you please get me through how this is working
Your tests are not adequate to understand
choroba's suggested code. Try this (demonstrated here under the Perl debugger):
DB<1> $string = 'Tetsing " code implementationm';
DB<2> $result = $string =~ tr/"//;
DB<3> p $result
1
DB<4> p $string
Tetsing " code implementationm
In essence,
choroba is testing the value that ends up into $result in the code above. And it adds a quote mark at the end of the string if the value returned by tr/// is odd (meaning that quote marks are unbalanced).