develooper Front page | perl.fwp | Postings from March 2005

Re: Self-recognizing programs and regular expressions

Thread Previous | Thread Next
From:
Karsten Sperling
Date:
March 8, 2005 07:54
Subject:
Re: Self-recognizing programs and regular expressions
Message ID:
1421490643.20050308165418@stud.uni-karlsruhe.de
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


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About