You're replying to a comment by Peter Krumins.

December 14, 2009, 13:49

Samuel, interesting. I just changed "my $regex" to "$regex" and it works.

$ perl

$str = "0"x50 . "1"x50;
$regex = qr/0(??{$regex})*1/;

if ($str =~ /^$regex$/) {
  print "yes, it matches\n"
else {
  print "no, it doesn't match\n"

I am not exactly sure why the lexically scoped variable changed whether it matches or not. I am investigating this now.

Update: Can't do that because lexical variables aren't visible during their own initialization! That is, you can't use a lexical in the same statement that declares it. I didn't think about it when I wrote those regexes.

I fixed the article everywhere and it should now be correct. :)

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "0day_180": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.