Since you are asking about database-like operations, why don't you use one of the modules that treats "delimited" text files as databases. Both
DBD::CSV and
DBD::AnyData can handle the kinds of files you show. If you know SQL, you can simply use ORDER BY to sort on any column, CREATE TABLE AS SELECT to make new tables from combinations of old tables, etc. If you don't know SQL, you can use those same modules with
Tie::DBI or
Class::DBI as front ends that will hide the SQL from you.