zentara wrote: > On Fri, 11 Jan 2002 04:39:05 -0800, [EMAIL PROTECTED] (John W. Krahn) wrote: > > >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? > >> > >> 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'); > > >John wrote: > > > >The example actually is: > > > >( $base, $path, $type ) = fileparse( '/virgil/aeneid/draft.book7', '\.book\d+' ); > > > >Where the second argument to fileparse() is a regular expression (which > >is why there is a back-slash in front of the period.) > > If you have to tell it the extension beforehand, then it dosn't > seem to be very useful in extracting the extension.
If you just want the extension for a filename, this should work my $filename = "/virgil/aeneid/draft.book7"; my $extn = substr ($filename, rindex ($filename, '.')); This should store '.book7' in extn. hth, Sudarsan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]