my $regex = join '|', map "\Q$_\E?", @filelist; ^ ^ ^ ^^ | | | || | | | |+ - Last character in file name optional, i.e., the "l" in html | | | + - End quote metacharacters | | + - The default scalar aliased to each @filelist element | + - Begin quote metacharacters (e.g., the period) + - Join each element with alternation ("or") character