in reply to how to escape ' character

You usually don't have to escape ' at all:

# these are not escaped print "'"; print qq('); print q('); print <<ENDLINE; some line with a ' in it ENDLINE # this one is escaped print '\'';