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. I hope this question makes sense.
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.
\ttab (HT, TAB)\nnewline (NL)\rreturn (CR)\fform feed (FF)\bbackspace (BS)\aalarm (bell) (BEL)\eescape (ESC)\033octal char (example: ESC)\x1bhex char (example: ESC)\x{263a}wide hex char (example: SMILEY)\c[control char (example: ESC)\N{name}named Unicode character
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With