in reply to Re^2: elements not reversing inside a mapin thread elements not reversing inside a map
To parse the file extension, just capture the text following the last .:
$filename =~ /(?<=\.)([^.]+)$/;