The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

autoindex ($directory, sort_field => "name", fs_encoding => "utf-8")

The autoindex function takes as argument a directory and an optional named sort_field parameter for sorting, and returns a arrayref with hashrefs with the relevant file information:

[
{
'location' => './../',
'mod_time' => '08-Apr-2013 12:58',
'name' => '..',
'size' => '-'
},
{
'location' => 'test.txt',
'mod_time' => '08-Apr-2013 15:04',
'name' => 'test.txt',
'size' => '13B'
}
];

You may want to specify a sort_field parameter to sort the listing (by default "name") and a file system encoding (by default "utf-8");