It looks like
SpeechSynthesizer.GetInstalledVoices returns something like an array, and you converted that to a hash pointing to array indexes. Why not simply use the
array, and let
List::Util's
first give you the index directly? For your problem with index 0, replace the first array element with something unmatchable, and if
first returns
undef, it's the case where you have to use 0 anyway.
my @voices = ...(whatever you do to get the voices array)
my $voicezero = $voices[0]; # if name of voice needed later
$voices[0] = 'least-liked';
my $voice = first { m/$language/ } @voices || 0;
$voices[0] = $voicezero; # if name of voice needed later
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.