AFAICT, there are 2 possibilities:
(1) You are sending a Ctrl-C from one process to another. In that case, forget about regexen — you need a signal handler. See Signals.
(2) You are sending “\x03” as the argument to a subroutine within the same process. In that case, it makes sense to match it with a regex. And there are two options:
(2a) Suppress interpolation and match the string character-by-character. That is in fact what you did in the OP, which does print Matched !! contrary to the claim made there.
(2b) Interpolate and match with \cC in the regex, as per Kenosis’s original answer:
16:46 >perl -Mstrict -wE "say 'Matched !!' if '\x03' =~ /\\x03/;"
Matched !!
16:46 >perl -Mstrict -wE "say 'Matched !!' if qq[\x03] =~ /\\x03/;"
16:46 >perl -Mstrict -wE "say 'Matched !!' if qq[\x03] =~ /\cC/;"
Matched !!
16:46 >
Hope that helps,
Athanasius <°(((>< contra mundum
|