I'm writing a script for IRC, and sometimes I might need to use a color. Normally I do it this way:
my $C = chr(3);
$C
is the control code used for color, but I've seen some other script that escapes it something like "\x\v...". How do I get the correct encoded version of that? I tried Data::Dumper
, but I didn't find it.
The way to specify chr(3)
with a hexadecimal escape code is to use:
print "\x03\n";
or, in octal:
print "\003\n";
or, as a control code:
print "\cC\n";
See perldoc perlop:
The following escape sequences are available in constructs that interpolate and in transliterations.
\t
tab (HT, TAB)\n
newline (NL)\r
return (CR)\f
form feed (FF)\b
backspace (BS)\a
alarm (bell) (BEL)\e
escape (ESC)\033
octal char (example: ESC)\x1b
hex char (example: ESC)\x{263a}
wide hex char (example: SMILEY)\c[
control char (example: ESC)\N{name}
named Unicode character