#!usr/bin/perl -w use strict; my @strings = glob "{abc}{0,p,z}"; #to enumerate the combinations print "@strings\n"; #abc0 abcp abcz #### my $prefix = 'abc'; my $endingLetters = '0pz'; if (/$prefix[$endingLetters]/){...}