
Perl: the Markov chain saw


by root (Scribe)
on Dec 23, 1999 at 00:51 UTC ( #1201=perlfunc: print w/ replies, xml ) Need Help??


See the current Perl documentation for File::Basename.


fileparse - split a pathname into pieces

basename - extract just the filename from a path

dirname - extract just the directory from a path

    use File::Basename;

    $basename = basename($fullname,@suffixlist);
    $dirname = dirname($full



You select the syntax via the routine fileparse_set_fstype().

If the argument passed to it contains one of the substrings ``VMS'', ``MSDOS'', ``MacOS'', ``AmigaOS'' or ``MSWin32'', the file specification syntax of that operating system is used in future calls to fileparse(), basename(), and dirname(). If it contains none of these substrings, UNIX syntax is used. This pattern matching is case-insensitive. If you've selected VMS syntax, and the file specification you pass to one of these routines contains a ``/'', they assume you are using UNIX emulation and apply the UNIX syntax rules instead, for that function call only.

If the argument passed to it contains one of the substrings ``VMS'', ``MSDOS'', ``MacOS'', ``AmigaOS'', ``os2'', ``MSWin32'' or ``RISCOS'', then the pattern matching for suffix removal is performed without regard for case, since those systems are not case-sensitive when opening existing files (though some of them preserve case on file creation).






Using UNIX file syntax:


would yield

    $base eq 'draft'
    $path eq '/virgil/aeneid/',
    $type eq '.book7'

Similarly, using VMS syntax:


would yield

    $name eq 'Rhetoric'
    $dir  eq 'Doc_Root:[Help]'
    $type eq '.Rnh'




Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (13)
As of 2013-12-20 17:31 GMT
Find Nodes?
    Voting Booth?

    How do you parse XML?

    Results (431 votes), past polls