Reputation: 8428
i'm currently using File::Basename fileparse to separate out a file's directory, base file name and it's extension using something like this:
my($myfile_name,$mydirectory, $file_extension) = fileparse($$rhash_params{'storage_full_path_location'},'\..{1,4}');
But see that there's a variation where you can actually provide a array of suffixes to the function, the array would contains all the known file extension.
So i'm trying to find a safe way to do this as i've seen that i've got some strange file names to process, i.e. file.0f1.htm, etc.
And if there's an even better way to do this, please share.
Thanks.
So obviously i must be drunk to forgot about those other extension. :) Thus i've updated the current regex to allow from 1-4chars.
In this case, how should i change my regex line to properly match it? Or is it an even better idea to look for all those commonly used extension from google and put them into an array to be passed to the function instead? My users are usually either students or teachers.
Upvotes: 1
Views: 1511
Reputation: 308131
There are several fault assumptions in your code:
Upvotes: 1
Reputation: 339917
1
. Is there a list of commonly used extension for Windows and Unix systems? But in my case it's mainly for Windows.
Yes, loads, all over the internet: http://www.google.com/search?q=common+file+extensions
2
. And is it safe to assume that all file names in Windows should have an extension ending with three letter characters?
No, it's perfectly possible to use '.c'
, '.java'
, etc in Windows.
Upvotes: 3