Real Programmers/ Cheat Sheet/ Perl/ Print C String
Google site:

Print C Strings in Perl

As anyone familiar with Perl knows, the perl language parser performs backslash substitution in double-quoted strings so character sequences like \n are converted into their "real" printable forms.

But how do you perform the reverse operation, say taking a literal tab and printing "\t"? The Perl Compiler suite, the B modules, handily contains such a function:

use B;

print B::cstring("\tWow it works!\n");
produces, predictably enough:
"\tWow it works!\n"

All non-user content and code Copyright © 2000-2006 / Paul Makepeace. Comments & feedback welcome!