File::Groups - File extensions and media types, grouped by application and type
Methods on File::Groups return classes containing a set of media types and file extensions. These are accessible via the media_types and extensions methods, which return Array refs of values. By default only commonly used values are returned. To return all know values pass 1 to either method, e.g., class->media_types(1)
File::Groups
media_types
extensions
1
class->media_types(1)
In some cases additional methods can be called on the object to further restrict the set.
Let's look at some examples.
Retrieve a list of file extensions or media types used by images and video:
use File::Groups; File::Groups->image->extensions; # ['bmp', 'gif', 'ico', 'jpeg', ... ] File::Groups->image->media_types; # ['image/bmp', 'image/x-ms-bmp', 'image/gif', ... ] File::Groups->video->extensions; # ['asf', 'mov', 'qt', 'movie', ... ] File::Groups->video->media_types; # ['video/x-ms-asf', 'video/quicktime', ... ]
Images can be filtered on by raster, vector, or web:
File::Groups->image->web->extensions; # ['gif', 'jpeg', 'jpg', 'png', 'svg', 'webp'] File::Groups->image->raster->extensions; # ['bmp', 'gif', 'ico', 'jpeg', 'jpg', 'tif', 'tiff', 'webp'] File::Groups->image->vector->extensions; # ['svg']
For a complete list pass 1 to any of these methods:
File::Groups->image->web->extensions(1); # ['bmp', 'dib', 'gif', 'ico', 'jfif', 'jpe', 'jpeg', ... ]
Retrieve a list of file extensions or media types used by spreadsheets:
use File::Groups; File::Groups->spreadsheet->extensions; # ['csv', 'xls', 'xlsx', 'xlt', ... ] File::Groups->spreadsheet->media_types; # ['text/csv', 'application/vnd.ms-excel', ... ]
If you only want values specific to Microsoft Excel:
File::Groups->spreadsheet->excel->extensions; # ['xls', 'xlsx', 'xlt', 'xltx', 'xlw'] File::Groups->spreadsheet->excel->media_types; # ['application/vnd.ms-excel', ... ]
Or for OpenOffice Calc:
File::Groups->spreadsheet->calc->extensions; # ['ods', 'ots']
By default these only return common extensions, to return all:
File::Groups->spreadsheet->excel->extensions(1); # ['xls', 'xlsx', 'xlt', 'xltx', ... ]
See https://github.com/sshaw/file_groups/blob/master/README.md#groups.
Skye Shaw (skye.shaw -AT- gmail)
Copyright (c) 2020 Skye Shaw. All rights reserved.
https://opensource.org/licenses/MIT
1 POD Error
The following errors were encountered while parsing the POD:
alternative text 'https://github.com/sshaw/file_groups/blob/master/README.md#groups' contains non-escaped | or /
To install File::Groups, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::Groups
CPAN shell
perl -MCPAN -e shell install File::Groups
For more information on module installation, please visit the detailed CPAN module installation guide.