heezy has asked for the wisdom of the Perl Monks concerning the following question:
I have a hash containing language codes..
my %validLanguages = ( "de" => "german", "en" => "english", "es" => "spanish", "fr" => "french", "it" => "italian", "ja" => "jap", "ko" => "korean", "ru" => "rus, "sv" => "WHATS THIS", "zh" => "WHATS THIS", "zh_TW" => "WHATS THIS" );
...and I want to build a procedure that checks if a piece of text passed to it as a parameter is made up of only...
How easy is this to do? I thought I could just use a regex but then I wanted to call the keys of the hash in it and it all got far to complicated.
This is how far I got :(
# returns any value if it is a valid list e.g... # "de, en, fr, ja" # return undef if it is not a valid list e.g... # "monkish fr, en" # a valid list will always be in the form... # language,\slanguage,\slanguage.... sub isItJustAListOfLanguages{ my %validLanguages = ( "de" => "german", "en" => "english", "es" => "spanish", "fr" => "french", "it" => "italian", "ja" => "japanise", "ko" => "korean", "ru" => "russian", "sv" => "WHATS THIS", "zh" => "WHATS THIS", "zh_TW" => "WHATS THIS" ); $textToTest = $_[0]; }
Help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex checking text is made up of the keys of a hash.
by Zaxo (Archbishop) on Mar 01, 2003 at 03:02 UTC | |
|
Re: Regex checking text is made up of the keys of a hash.
by blakem (Monsignor) on Mar 01, 2003 at 03:04 UTC | |
by heezy (Monk) on Mar 01, 2003 at 23:04 UTC | |
|
Re: Regex checking text is made up of the keys of a hash.
by BrowserUk (Patriarch) on Mar 01, 2003 at 04:15 UTC | |
|
Re: Regex checking text is made up of the keys of a hash.
by hv (Prior) on Mar 01, 2003 at 14:19 UTC | |
|
Re: Regex checking text is made up of the keys of a hash.
by heezy (Monk) on Mar 01, 2003 at 23:08 UTC |