NAME String::PerlQuote - Quote a string like Perl does VERSION This document describes version 0.01 of String::PerlQuote (from Perl distribution String-PerlQuote), released on 2014-12-10. FUNCTIONS double_quote($str) => STR Quote or encode $str to the Perl double quote (""") literal representation of the string. Example: say double_quote("a"); # => "a" (with the quotes) say double_quote("a\n"); # => "a\n" say double_quote('"'); # => "\"" say double_quote('$foo'); # => "\$foo" This code is taken from "quote()" in Data::Dump. Maybe I didn't look more closely, but I couldn't a module that provides a function to do something like this. String::Escape, for example, provides "qqbackslash" but it does not escape "$". single_quote($str) => STR Like "double_quote" but will produce a Perl single quote literal representation instead of the double quote ones. In single quotes, only literal backslash "\" and single quote character "'" are escaped, the rest are displayed as-is, so the result might span multiple lines or contain other non-printable characters. say single_quote("Mom's"); # => 'Mom\'s' (with the quotes) say single_quote("a\\"); # => 'a\\" say single_quote('"'); # => '"' say single_quote("\$foo"); # => '$foo' HOMEPAGE Please visit the project's homepage at . SOURCE Source repository is at . BUGS Please report any bugs or feature requests on the bugtracker website When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. AUTHOR perlancar COPYRIGHT AND LICENSE This software is copyright (c) 2014 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.