in reply to creating a regular expression's alternation dynamically?
You may want to look into the regex quotation operator, qr. The $" variable can be used to force alternation into a quoted array.
I've demonstrated some tricks which reduce the visual noise. chomp can be applied to a list, the diamond op returns all lines in array context, and the elements of a quoted array are seperated by $".#!/usr/bin/perl use warnings; use strict; chomp(my @list = <DATA>); my $regex = do { local $" = '|'; qr/@list/; }; print $regex, $/; my $s = 'huey'; print "match:\t$s\n" if $s =~ $regex; __DATA__ huey dewey louie
After Compline,
Zaxo
|
|---|