in reply to Re: Getting a file's extension in an upload form
in thread Getting a file's extension in an upload form

Good answer, but then what? fileparse has to have a list of acceptable extensions before it will strip them. So if you don't know what extensions to use ahead of time, File::Basename is not going to be much help at all. Try the following one-liners to see what i mean.

perl -MFile::Basename -le"print for fileparse('/path/to/foo.txt.bak')" perl -MFile::Basename -le"print for fileparse('/path/to/foo.txt.bak',' +.bak')" perl -MFile::Basename -le"print for fileparse('/path/to/foo.txt.bak',' +.txt')" perl -MFile::Basename -le"print for fileparse('/path/to/foo.txt.bak',' +.txt.bak')"
If you know of a generic regex to pass to fileparse, i would really love to know what it is. But, the problem of knowing just which extension to pull out of foo.bar.baz.qux is tough with or without File::Basename (which i think is a fantabulous module, BTW). That is just something that the coder has to determine ahead of time ... probably a good thing considering the dangers of file uploading.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)