To start with you may want to have a thorough look to the documentation on modules, for example this: http://perldoc.perl.org/perlmod.html. Then you will need to go to the CPAN and look for existing modules that can take care of the various formats you need to handle.