start page | rating of books | rating of authors | reviews | copyrights

Book HomeJava and XSLTSearch this book

8.95. File::Basename

Parses a file's path, returning its three component pieces: the path to the file, the file's basename, and the file's extension. For example, for:

/usr/local/lib/perl5/SelectSaver.pm

the path is /usr/local/lib/perl5, the basename is SelectSaver, and the extension is .pm. File::Basename exports the following functions.

basename

basename (fullname[, suffixlist])

Returns the first element of the list that would be produced if you called fileparse with the same arguments. Provides compatibility with the Unix basename command. Takes the following arguments:

fullname
Input file specification

suffixlist
Optional list containing patterns to be matched against the end of fullname to find the suffix

dirname

dirname (fullname)

Returns the directory portion of the input file specification. fullname is the input file specification.

fileparse

fileparse (fullname[, suffixlist])

Divides a file specification into its three parts, returning them in this order: filename, path, suffix.

($name, $path, $suffix) = fileparse($fullname, @suffixlist)

The arguments are the same as for basename.

fileparse_set_fstype

fileparse_set_fstype (os-string)

Called before the other routines to select the appropriate file specification syntax for your operating system, to be used in future File::Basename calls. Currently valid values for os-string (the operating system) are VMS, MSWin32, MSDOS, AmigaOS, os2, RISCOS, and MacOS. Uses Unix syntax by default.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.