in reply to Regular Expression Question

my %regexen = ( v => qr/[aeiou]/i; c => qr/[a-z^aeiou]/i; ); # This is inputted somehow. my $pattern = 'cccv'; my $regex = join '', map { $regexen{$_} } split //, $pattern; # Get @dictionary somehow. foreach my $word (@dictionary) { print "$word matches" if $word =~ /$pattern/; }
Note - this code is very untested.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: Regular Expression Question
by perlguy (Deacon) on Apr 03, 2003 at 20:52 UTC

    Just out of curiosity, when you join pre-compiled regexen as dragonchild did above, and stick the result into a variable, is the variable now treated like a pre-complied regex, or will it need to be recompiled again each time during the foreach loop?