Just another Perl shrine | |
PerlMonks |
Re: Matching wirth ordered arrayby choroba (Cardinal) |
on Mar 18, 2019 at 22:52 UTC ( [id://1231410]=note: print w/replies, xml ) | Need Help?? |
Sorting by the length starting from the longest is a common way. Instead of looping over the dictionary, you can build a regex from all the terms, and return the translation based on the matching part. Also, storing the dictionary in a hash makes retrieving the translation easier and faster. Something like the following:
Output:
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
In Section
Seekers of Perl Wisdom
|
|