try this
# Implement Perl tr function
function perl_tr(s::AbstractString, target::AbstractString, rep::AbstractString)
@assert length(target) == length(rep)
Base.replace(collect(s), Dict(zip(target,rep))...) |> join
end
let
mystring = "The cat sat on the mat"
mystring = perl_tr(mystring,"ao","oL")
println(mystring)
end
typecasting it to AbstractString could make it faster.