I'm trying to write all new Perl code in Perl 6.  One thing I need is
the equivalent of the Perl 5 qr// and, following Perl 6 docs, I've
come to use something like this (I'm trying to ignore certain
directories):

# regex of dirs to ignore
my regex dirs {
  \/home\/user\/\.cpan |
  \/home\/tbrowde\/\.emacs
}

for "dirlist.txt".IO.lines -> $line {
  # ignore certain dirs
  if $line ~~ m{<dirs>} {
     next;
  }
}

My question: Is there a way to have Perl 6 do the required escaping
for the regex programmatically, i.e., turn this:

my $str = '/home/usr/.cpan';

into this:

my regex dirs {
  \/home\/usr\/\.cpan
}

automatically?

Thanks.

Best regards,

-Tom

Reply via email to