safename#

Return a string with a leading control character rendered as ^X.

Synopsis#

use B qw(safename);
safename("\cGx");     # "^Gx"
safename("\x7f");     # "^?"
safename("a\cG");     # "a\cG" - only the first character is converted

A first character in \cA to \cZ, \c[, \c\, \c], \c^ or \c_ becomes ^ followed by the matching printable character, and \c? (DEL) becomes ^?; everything else is returned unchanged. This is the conversion B::GV::SAFENAME applies to a glob’s name, and the form Perl source uses for variables such as ${^WARNING_BITS}.

Exported on request.