Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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 };

In reply to Re: Testing for the presence of a hash key in a filename by blazar
in thread Testing for the presence of a hash key in a filename by NovMonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found