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 };
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|