FILE::SPEC::WIN32(3perl)
β¨ File::Spec::Win32 β methods for Win32 file specs β¨
okay bestie, so this little page is the Win32-flavored sibling of File::Spec::Unix, and it lives in the Perl world (it's a perl manual page, specifically File::...::Win32(3perl) β yes the name really does get truncated like that in the header, iconic). It's all about messing with file specs the Windows way. πͺπ
π SYNOPSIS π
require File::Spec::Win32; # Done internally by File::Spec if needed
tl;dr you basically never load this yourself β File::Spec pulls it in on its own when it needs it. periodt.
πΈ DESCRIPTION πΈ
So here's the vibe: for actual documentation of the methods, go see File::Spec::Unix. This package overrides the implementation of those methods, not the semantics. Same energy, different plumbing. π«Ά
π¦ devnull
Returns a string representation of the null device. that's it, that's the whole thing. π
π tmpdir
Returns a string representation of the first existing directory from this list, top to bottom:
$ENV{TMPDIR}
$ENV{TEMP}
$ENV{TMP}
SYS:/temp
C:\system\temp
C:/temp
/tmp
/
heads up: SYS:/temp is the preferred one on Novell NetWare, and C:\system\temp is the fave for Symbian (because File::Spec::Win32 gets used on those platforms too, no cap).
and if you're running under taint mode and the environment variables are tainted? they get skipped entirely. not used. bye. π
π case_tolerant
On MSWin32, case-tolerance depends on GetVolumeInformation() with $ouFsFlags == FS_CASE_SENSITIVE, which is what tells you whether case matters when comparing file specifications. Since XP, FS_CASE_SENSITIVE is effectively disabled for the NT subsubsystem. See <http://cygwin.com/ml/cygwin/2007-07/msg00891.html>
Default: 1
π§ file_name_is_absolute
As of right now (yes, right now, that's literally what it says), this returns:
2if the path is absolute with a volume1if it's absolute with no volume0otherwise
π₯ catfile
Concatenate one or more directory names and a filename to form a complete path ending with a filename. slay. β¨
π canonpath
No physical check on the filesystem here, bestie β just a logical cleanup of a path.
On UNIX it eliminates successive slashes and successive "/.". On Win32 it makes:
dir1\dir2\dir3\..\..\dir4 -> \dir\dir4 and even
dir1\dir2\dir3\...\dir4 -> \dir\dir4
π splitpath
($volume,$directories,$file) = File::Spec->splitpath( $path );
($volume,$directories,$file) = File::Spec->splitpath( $path,
$no_file );
Splits a path into volume, directory, and filename portions. It assumes that the last file is a path unless the path ends in '\\', '\\.', '\\..' or $no_file is true. On Win32 this means that $no_file being true makes this return ( $volume, $path, '' ).
Separators it accepts are \ and /. yes, both. we're flexible like that. π«Ά
Volumes can be drive letters or UNC sharenames (\\server\share).
The results can be passed to "catpath" to get back a path equivalent to (usually identical to) the original path. π«
β splitdir
The opposite of catdir().
@dirs = File::Spec->splitdir( $directories );
$directories must be only the directory portion of the path on systems that have the concept of a volume, or that have path syntax which differentiates files from directories.
And here's the twist: unlike just splitting the directories on the separator, leading empty and trailing directory entries can be returned, because these are significant on some OSs. So:
File::Spec->splitdir( "/a/b//c/" );
Yields:
( '', 'a', 'b', '', 'c', '' )
see how it's giving empty strings at both ends? that's not a bug, that's the whole point. π
π catpath
Takes volume, directory and file portions and returns an entire path. Under Unix, $volume is ignored and this is just like catfile(). On other OSs, the $volume becomes significant. π
π Note For File::Spec::Win32 Maintainers π
Novell NetWare inherits its File::Spec behaviour from File::Spec::Win32. if you're touching this file, that's your problem now too. π
π COPYRIGHT π
Copyright (c) 2004,2007 by the Perl 5 Porters. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π SEE ALSO π
See File::Spec and File::Spec::Unix. This package overrides the implementation of these methods, not the semantics. (yes, we said it twice, because it matters, okay? π)
and that's the whole page, bestie!! πβ¨ this lil beauty is from perl v5.44.0, dated 2026-10-17, and it's filed under File::...::Win32(3perl) β go forth and concatenate responsibly. mwah. ππ¦
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms