in reply to CPAN module for generating regexp matches

#!usr/bin/perl -w use strict; my @strings = glob "{abc}{0,p,z}"; #to enumerate the combinations print "@strings\n"; #abc0 abcp abcz
You can make a regex out of these combinations, $regex=join("|",@strings); or what you had is fine  /abc[0pz]/

note: that abc or the character set 0pz could be Perl variables ($prefix or $endingLetters or whatever).

my $prefix = 'abc'; my $endingLetters = '0pz'; if (/$prefix[$endingLetters]/){...}