1File::Spec::Unix(3)   User Contributed Perl Documentation  File::Spec::Unix(3)
2
3
4

NAME

6       File::Spec::Unix - File::Spec for Unix, base for other File::Spec
7       modules
8

SYNOPSIS

10        require File::Spec::Unix; # Done automatically by File::Spec
11

DESCRIPTION

13       Methods for manipulating file specifications.  Other File::Spec
14       modules, such as File::Spec::Mac, inherit from File::Spec::Unix and
15       override specific methods.
16

METHODS

18       canonpath()
19         No physical check on the filesystem, but a logical cleanup of a path.
20         On UNIX eliminates successive slashes and successive "/.".
21
22             $cpath = File::Spec->canonpath( $path ) ;
23
24         Note that this does *not* collapse x/../y sections into y.  This is
25         by design.  If /foo on your system is a symlink to /bar/baz, then
26         /foo/../quux is actually /bar/quux, not /quux as a naive ../-removal
27         would give you.  If you want to do this kind of processing, you
28         probably want "Cwd"'s "realpath()" function to actually traverse the
29         filesystem cleaning up paths like this.
30
31       catdir()
32         Concatenate two or more directory names to form a complete path
33         ending with a directory. But remove the trailing slash from the
34         resulting string, because it doesn't look good, isn't necessary and
35         confuses OS2. Of course, if this is the root directory, don't cut off
36         the trailing slash :-)
37
38       catfile
39         Concatenate one or more directory names and a filename to form a
40         complete path ending with a filename
41
42       curdir
43         Returns a string representation of the current directory.  "." on
44         UNIX.
45
46       devnull
47         Returns a string representation of the null device. "/dev/null" on
48         UNIX.
49
50       rootdir
51         Returns a string representation of the root directory.  "/" on UNIX.
52
53       tmpdir
54         Returns a string representation of the first writable directory from
55         the following list or the current directory if none from the list are
56         writable:
57
58             $ENV{TMPDIR}
59             /tmp
60
61         If running under taint mode, and if $ENV{TMPDIR} is tainted, it is
62         not used.
63
64       updir
65         Returns a string representation of the parent directory.  ".." on
66         UNIX.
67
68       no_upwards
69         Given a list of file names, strip out those that refer to a parent
70         directory. (Does not strip symlinks, only '.', '..', and
71         equivalents.)
72
73       case_tolerant
74         Returns a true or false value indicating, respectively, that
75         alphabetic is not or is significant when comparing file
76         specifications.
77
78       file_name_is_absolute
79         Takes as argument a path and returns true if it is an absolute path.
80
81         This does not consult the local filesystem on Unix, Win32, OS/2 or
82         Mac OS (Classic).  It does consult the working environment for VMS
83         (see "file_name_is_absolute" in File::Spec::VMS).
84
85       path
86         Takes no argument, returns the environment variable PATH as an array.
87
88       join
89         join is the same as catfile.
90
91       splitpath
92             ($volume,$directories,$file) = File::Spec->splitpath( $path );
93             ($volume,$directories,$file) = File::Spec->splitpath( $path,
94                                                                   $no_file );
95
96         Splits a path into volume, directory, and filename portions. On
97         systems with no concept of volume, returns '' for volume.
98
99         For systems with no syntax differentiating filenames from
100         directories, assumes that the last file is a path unless $no_file is
101         true or a trailing separator or /. or /.. is present. On Unix this
102         means that $no_file true makes this return ( '', $path, '' ).
103
104         The directory portion may or may not be returned with a trailing '/'.
105
106         The results can be passed to "catpath()" to get back a path
107         equivalent to (usually identical to) the original path.
108
109       splitdir
110         The opposite of "catdir()".
111
112             @dirs = File::Spec->splitdir( $directories );
113
114         $directories must be only the directory portion of the path on
115         systems that have the concept of a volume or that have path syntax
116         that differentiates files from directories.
117
118         Unlike just splitting the directories on the separator, empty
119         directory names ('') can be returned, because these are significant
120         on some OSs.
121
122         On Unix,
123
124             File::Spec->splitdir( "/a/b//c/" );
125
126         Yields:
127
128             ( '', 'a', 'b', '', 'c', '' )
129
130       catpath()
131         Takes volume, directory and file portions and returns an entire path.
132         Under Unix, $volume is ignored, and directory and file are
133         concatenated.  A '/' is inserted if needed (though if the directory
134         portion doesn't start with '/' it is not added).  On other OSs,
135         $volume is significant.
136
137       abs2rel
138         Takes a destination path and an optional base path returns a relative
139         path from the base path to the destination path:
140
141             $rel_path = File::Spec->abs2rel( $path ) ;
142             $rel_path = File::Spec->abs2rel( $path, $base ) ;
143
144         If $base is not present or '', then cwd() is used. If $base is
145         relative, then it is converted to absolute form using "rel2abs()".
146         This means that it is taken to be relative to cwd().
147
148         On systems that have a grammar that indicates filenames, this ignores
149         the $base filename. Otherwise all path components are assumed to be
150         directories.
151
152         If $path is relative, it is converted to absolute form using
153         "rel2abs()".  This means that it is taken to be relative to cwd().
154
155         No checks against the filesystem are made, so the result may not be
156         correct if $base contains symbolic links.  (Apply Cwd::abs_path()
157         beforehand if that is a concern.)  On VMS, there is interaction with
158         the working environment, as logicals and macros are expanded.
159
160         Based on code written by Shigio Yamaguchi.
161
162       rel2abs()
163         Converts a relative path to an absolute path.
164
165             $abs_path = File::Spec->rel2abs( $path ) ;
166             $abs_path = File::Spec->rel2abs( $path, $base ) ;
167
168         If $base is not present or '', then cwd() is used. If $base is
169         relative, then it is converted to absolute form using "rel2abs()".
170         This means that it is taken to be relative to cwd().
171
172         On systems that have a grammar that indicates filenames, this ignores
173         the $base filename. Otherwise all path components are assumed to be
174         directories.
175
176         If $path is absolute, it is cleaned up and returned using
177         "canonpath()".
178
179         No checks against the filesystem are made.  On VMS, there is
180         interaction with the working environment, as logicals and macros are
181         expanded.
182
183         Based on code written by Shigio Yamaguchi.
184
186       Copyright (c) 2004 by the Perl 5 Porters.  All rights reserved.
187
188       This program is free software; you can redistribute it and/or modify it
189       under the same terms as Perl itself.
190
191       Please submit bug reports and patches to perlbug@perl.org.
192

SEE ALSO

194       File::Spec
195
196
197
198perl v5.32.1                      2021-01-27               File::Spec::Unix(3)
Impressum