Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: CTRL+C Regular Expression

by Athanasius (Chancellor)
on Nov 07, 2012 at 06:48 UTC ( #1002642=note: print w/replies, xml ) Need Help??


in reply to CTRL+C Regular Expression

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

Replies are listed 'Best First'.
Re^2: CTRL+C Regular Expression
by wirito (Acolyte) on Nov 07, 2012 at 11:31 UTC
    Also:
    $ perl -e '"\x03" =~ /\x03/ and print "Matched!\n"' Matched! $ perl -e 'chr(3) =~ /\x03/ and print "Matched!\n"' Matched! $ perl -e '3 =~ /\x03/ and print "Matched!\n"'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002642]
help
Chatterbox?
[LanX]: yes. But YM is a friend who asked for wisdom, though this sub-thread should be a meditation
[LanX]: ehm ... nope ... a PM discussion not a meditation
[LanX]: I spend too much time in this alsmhouse ... cheers o/
[Discipulus]: what articular point of view.. i intrepreted the only question mark as rethoric.. but i'm strange

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-11-23 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (337 votes). Check out past polls.

    Notices?