Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Testing for the presence of a hash key in a filename

by blazar (Canon)
on May 25, 2007 at 15:58 UTC ( [id://617526]=note: print w/replies, xml ) Need Help??


in reply to Testing for the presence of a hash key in a filename

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 };

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://617526]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2024-04-18 14:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found