in reply to Re: Re: Good Idiom for Matching List?
in thread Good Idiom for Matching List?

# Perl 6 code my $goodnames = /@names/;
No qr? How can it tell that I didn't mean to match against $_ now and set $goodnames to the success condition?

Update: Downvoters: This is a serious question, not a slam on Damian. I saw something "different", from someone who knows about it, and wanted more details. You can see from the reply that there is indeed something interesting and different happening here. In fact, I can imagine a section in the docs will discuss this very issue!

Replies are listed 'Best First'.
Re: typo or more changes coming our way?
by theorbtwo (Prior) on Dec 11, 2002 at 21:56 UTC

    In perl6, the /foo/ operator is qr-ish. However, in certian contexts (bool context, numeric context, stringy context, and basicly any other context that can't hold a regex), that means that the regex will be created, matched against, and then thrown away (that will probably get optimized a fair bit). However, yes, my $goodnames=/@names/ will set $goodnames to a regex that matches when any of the things in @names (taken literaly) match the target.


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).