Sum Human Formatted File Sizes

I have a list of human-formatted file sizes, each on a new line, like
this:

1
2
3
4
$ cat files.txt
210M
1G
300000K

This is what I did to add them all up and then convert the sum to a
human formatted number again:

1
2
$ cat files.txt | (while read line; do numfmt --from=auto $line; done) | perl -lne '$x+=$_; END{print $x;}' | numfmt --to=iec
1.5G