in reply to Those greedy quantifiers!

? is a quantifier in your first snippet (quantified atom matches optionally matches once) because it's not preceded by another quantifier. (And it happens to be useless in your pattern.)

? is a greediness modifier (makes it non-greedy) in your second snippet because it's preceded by a quantifier.

There's no reason to alter greediness here. Solution:

my %seen; my @exts = grep !$seen{$_}++, map /\.([^.]+)\z/, @file_names;