The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


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)

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/', ... ]

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/', ... ]

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', ... ]




Skye Shaw ( -AT- gmail)


Copyright (c) 2020 Skye Shaw. All rights reserved.


1 POD Error

The following errors were encountered while parsing the POD:

Around line 521:

alternative text '' contains non-escaped | or /