Re: Self-recognizing programs and regular expressions

Karsten Sperling <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
This is as far as I got:

^(?=.{65}\\\\Q\\1\\\\E\\\)\z)(\Q^(?=.{65}\\\\Q\\1\\\\E\\\)\z)(\E)\\Q\1\\E\)

It is a true inequ of sorts. However, it uses \Q, which is a quoting
construct, not a regex construct. So it doesn't work as  $x =~ /$x/,
only as $x =~ eval("qr/$x/"):

chomp(my $x = <<'EOF');
^(?=.{65}\\\\Q\\1\\\\E\\\)\z)(\Q^(?=.{65}\\\\Q\\1\\\\E\\\)\z)(\E)\\Q\1\\E\)
EOF
print "OK" if $x =~ eval("qr/$x/");

Going all the way to  $x = qr/.../; "$x" =~ $x;  doesn't help either,
because in the stringyfied version \Q-quoting is replaced by normal
\-escaping.

- Karsten
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.