Get the language code from the native language name in Perl
<p>When looking for a language's ISO369 code, this works fine with the English name of the language:</p>

<pre><code>perl -MLocale::Language -e 'print language2code("German"), "\n";'
de
</code></pre>

<p>But it does not work with the native language name:</p>

<pre><code>perl -MLocale::Language -e 'print language2code("Deutsch"), "\n";'
</code></pre>

<p>Background: I have text in a few languages and need to generate a HTML <code>hreflang</code> link. The text is always labeled with its native language name (e.g., "English", "Español", or "Deutsch"). I don't want to switch the (system) language before the lookup because I don't know to which language to switch. Right now I have my own lookup table that maps e.g., "English" => "en" and "Deutsch" => "de", but I was wondering if there was an easier way that does not need me to maintain that table.</p>

<p>How can I get from a language's native name to its ISO code?</p>