Perl can do this, and so can almost any other general purpose
language. You'd start by learning Perl (take a course, read
the manual, study one or more books that teach Perl). Alternatively, you'd program this exercise in a language you
do know.
Abigail