On Wed, 27 Jan 2016 14:14:17 +0000, Philip Hazelden <philip.hazel...@gmail.com> wrote:
> For a "convert files to $format" thing, you'd want to replace the > extension. You don't need to specify the previous extension(s) if it's a > quick-and-dirty thing where you know everything passed to it will be > acceptable; and you don't want to, if you're passing out to some other > service which can handle various input formats. (e.g. a wrapper around > ffmpeg or ImageMagick or something - they can handle a lot of filetypes > with a lot of likely extensions.) > > On Wed, Jan 27, 2016 at 1:43 PM 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? > > Is it for compressed files (e.g. .zip vs .tar.gz) or MS-DOS/Windows > > executables (.com, .exe, .bat), or something else? > > When I strip filename extensions, I usually know exactly what extensions > > I want to strip - e.g. ".conf" or ".pl" or something like that. There > > are very, very rare cases when any extension should be stripped - and > > there's also a problem with that. tcsh has stackable modifiers % set s=/tmp/bar/foo.a.b.c.d.e.f % echo $s /tmp/bar/foo.a.b.c.d.e.f % echo $s:h /tmp/bar % echo $s:r /tmp/bar/foo.a.b.c.d.e % echo $s:r:r /tmp/bar/foo.a.b.c.d % echo $s:r:r:r /tmp/bar/foo.a.b.c % echo $s:r:r:r:r /tmp/bar/foo.a.b % echo $s:r:r:r:r:r /tmp/bar/foo.a % echo $s:r:r:r:r:r:r /tmp/bar/foo % echo $s:r:r:r:r:r:r:r /tmp/bar/foo % echo $s:r:r:r:r:r:r:r:r /tmp/bar/foo % echo $s:t foo.a.b.c.d.e.f % echo $s:t:t foo.a.b.c.d.e.f % echo $s:t:t:r foo.a.b.c.d.e > > You see, I was kind of surprised many years ago when I first met > > somebody who routinely used a dot as a word separator in filenames - > > a file that I would've called "yearly-report.txt" or "YearlyReport.txt", > > he would call "yearly.report.txt". Over the years after that, I > > stumbled into many other people who do that - not a majority, certainly, > > but, well, many people indeed. > > > > 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. > > > > G'luck, > > Peter -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using perl5.00307 .. 5.23 porting perl5 on HP-UX, AIX, and openSUSE http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
pgphWKohF6PVz.pgp
Description: OpenPGP digital signature