in reply to how to escape ' character

Please show us the context for this question. In ordinary practice you don't need to escape quote marks. If this relates to a DBI query you *definitely* should not roll your own. Use $dbh->quote(), or even better, use placeholders.