On 1 Aug 2002 at 19:30, David Whipp wrote: > I'm wondering if Perl6's new regex can be applied to non-string things. I > seem to recall A5 mentioning something about strings tied to array > implementations; but I'm wanting something a little more powerful.
Yes, it can be applied to anything which can be tied to string. I didn't understand your message completely so I'll just copy-paste relevant parts from Synopsis 5, which IMO is easier to understand than A5. from http://dev.perl.org/perl6/synopsis/5.html Matching against non-strings * Anything that can be tied to a string can be matched against a regex. This feature is particularly useful with input streams: my @array := <$fh>; # lazy when aliased my $array is from(\@array); # tie scalar # and later... $array =~ m/pattern/; # match from stream Backtracking control * A <cut> assertion always matches successfully, and has the side effect of deleting the parts of the string already matched. * Attempting to backtrack past a <cut> causes the complete match to fail (like backtracking past a <commit>. This is because there's now no preceding text to backtrack into. * This is useful for throwing away successfully processed input when matching from an input stream or an iterator of arbitrary length. -- Markus Laire 'malaire' <[EMAIL PROTECTED]>