On Wednesday, January 27, 2016, Peter Pentchev <r...@ringlet.net> wrote: > > On Wed, Jan 27, 2016 at 07:00:11AM -0600, Tom Browder wrote: > > Given so many handy methods for built-in classes, it would be nice to have > > a couple of more for some, for instance: > > > > IO:Path.stemname > > Like basename except any suffix is removed > > Hmm, this sounds like a nice idea on a first glance, but then again, > can you tell me exactly what situations would that be useful for?
Well, for decades I have used Perl 5 File::Basename for getting the stem of a file name which I used in many automated data processing situations where the suffix indicates a type of product and the stem is, say, the project name. The docs show it done like this: my ($filename, $dirs, $suffix) = fileparse($path, @suffixes); where @suffixes can be a regular expression that includes all text after and including the last period. And any suffix is removed from the filename. > So a function that would remove *any* filename extensions, that is, > anything after and including the first dot, would produce really weird > results if applied to filenames created by such people. No, like IO:Path.suffix defines the suffix as at the last dot, stemname should consider the last dot. Thanks, Peter. -Tom