On Fri, Jan 11, 2002 at 07:16:29AM -0500, zentara wrote:
> I've been playing with File::Basename and
> the docs are not absolutely clear on whether
> you can get an extension on a linux system.
> I have had no success trying, so does this mean
> that linux is not capable of dealing with extensions?
In unix, and derivatives, extensions have no meaning at the OS level;
they're just part of the filename. Whether or not that means Linux is
capable of dealing with extensions depends on your point of view.
> As an example from perldoc File::basename:
> ###############################################
> #!/usr/bin/perl -w
> use strict;
> use File::Basename;
> my($base,$path,$type) = fileparse('/virgil/aeneid/draft.book7');
> print $base,"\n",$path,"\n",$type,"\n";
> #################################################
If you want to deal with any arbitrary extension, as defined as being
anything after the last ".", then you probably want:
my($base, $path, $ext) = fileparse($filename, '\.[^.]+$');
However, there are edge cases. I would consider .tar.gz to be the extension
of foo.tar.gz, so perhaps you want:
my($base, $path, $ext) = fileparse($filename, '\..*');
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]