Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Method returning a regex in Perl 6?

Tags: regex error

Eugene Barsky:

I'm only beginning to study classes, so I don't understand the basics.

I want a method to construct regex using attributes of the object:

class TEST {
has Str $.str;

method reg {


my $var = => 'baz');
say $var.reg;

When trying to run this program, I get the following Error message:

===SORRY!=== Error while compiling /home/evb/Desktop/p6/e.p6
Attribute $!str not available inside of a regex, since regexes are methods on Cursor.
Consider storing the attribute in a lexical, and using that in the regex.
at /home/evb/Desktop/p6/e.p6:11
------> ⏏
expecting any of:
infix stopper

So, what's the right way to do that?

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots

This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Method returning a regex in Perl 6?


Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription