I have a list of abbreviations that appear as part of a much longer filename, i.e. DNI,SNI,JRN, etc. Based on whether a particular combination appears anywhere in the filename, I have to call a corresponding color logo.
In addition to what others suggested, I have a question: I suppose that the order in which the abbreviations appear does not matter. But, for example, must filenames wich have respectively only DNI and SNI, only SNI and JRN, and all of DNI, SNI and JRN be associated to different logos? If so, then I would build the keys in terms of sorted abbreviations (possibly uniq'd too), joined on some standard separator:
my %logo = (
DNI => 'logo1',
JRN => 'logo2',
SNI => 'logo3',
DNI_JRN => 'logo4',
DNI_SNI => 'logo5',
JRN_SNI => 'logo6',
DNI_JRN_SNI => 'logo7',
);
# ...
print my $logo = $logo{ join '_', sort $name =~ /(DNI|JRN|SNI)/g };