If you have access to the Rails console, then you can set allowed email domains to an a pipe-delimited string with arbitrarily many hostnames, so that sounds workable.
Not sure why you would need numerical processing though; this can be done with standard UNIX tooling.
This gives you the list of domains from the Hipo list:
curl -L 'https://github.com/Hipo/university-domains-list/blob/master/world_universities_and_domains.json?raw=true' |
jq '.[].domains' |
jq -r add |
sort -u
If you saved that as domains.txt, and assuming you have a file with email addresses named emails.txt, you could get the subset of domains to allowlist with this:
grep -if domains.txt emails.txt |
cut -d @ -f 2 |
sort -u
That is, even if the domain list contains just tusculum.edu, an email like some.student@mail.tusculum.edu would yield mail.tusculum.edu which is the hostname you actually want to allowlist, as opposed to the apex.
Then it’s just a matter of setting a pipe delimited string containing these domains. Does that work for you?