Currency in x - tells you the currency in x country

Log in to Vote
33
33 Votes • 10 Comments
• posted 6 years and 3 months ago • type: Goodie (Perl functions) Live

anonymous
I think this plugin/idea should be tagged as Fathead instead of Goodie because "keywords database" should be enough (there is no need for API).

Simple solution is grab list of countries and currencies from Wikipedia.org and export output.txt file.

It is already done =) but I am new to GitHub so will see if I can manage uploading it there...
posted by [UserVoice Pavel] • 6 years and 2 months ago Link
anonymous
If there are any modules to do that then great.
But if it can help then I made a little parser in Python (if it is useless then no problem =):
https://github.com/Alchymista/zeroclicki...
With this output:
https://github.com/Alchymista/zeroclicki...
posted by [UserVoice Pavel] • 6 years and 2 months ago Link
anonymous
OK because I already posted updates here so here comes more:
- hash table is now directly included in 'CurrencyIn.pm' module
- when update is required then it can be generated and copy pasted from 'copy_paste_hash.txt'

Parser that generates 'copy_paste_hash.txt':
https://github.com/Alchymista/zeroclicki...

Module 'CurrencyIn.pm' can be found here:
https://github.com/Alchymista/zeroclicki...
posted by [UserVoice Pavel] • 6 years and 2 months ago Link
anonymous
Now it works with different search patterns {currency} {in|of|for}. For example:
What currency do I need in Egypt ?
What currency will I need for Zimbabwe
What is the currency used in Slovakia
currency in Russia
currency of Angola?

But doesn't work if there is more than one keyword {in|of|for}. For example
What type {of} currency do I need {for} Russia?
posted by [UserVoice Pavel] • 6 years and 2 months ago Link
anonymous
Excellent, this is much cleaner solution and now even "What type of currency do I need for Russia?" query works. Thank you =)
posted by [UserVoice Pavel] • 6 years and 2 months ago Link
yegg
Probably something in here https://metacpan.org/search?q=currency
posted by yegg Staff6 years and 2 months ago Link
yegg
posted by yegg Staff6 years and 1 month ago Link
yegg
I think you can drop the position thing and do something like this:

if ($_ =~ /^.*(?:in|of|for)\s(.*?)$/) {

Then the stuff after the last in/of/for will be in the $1 variable and you can just check that.

The ?: block just means don't capture.

Putting a ? after a * means not greedy. So the first .* captures all the way until the last in|of|for
posted by yegg Staff6 years and 2 months ago Link
yegg
Spice is the one for APIs. Goodies is a perl function that can leverage a hash or exsiting Perl module from CPAN. I put it there because like you said the data set is probably small and I figured there existed already a set of modules one could leverage.
posted by yegg Staff6 years and 2 months ago Link
yegg
Nice, well you could format that output as a perl hash or just use it as an input text file to the goodie.
posted by yegg Staff6 years and 2 months ago Link