File::Spec::Win32(3pm)
β¨ File::Spec::Win32 β methods for Win32 file specs β¨
Okay bestie, so this is the File::Spec::Win32 page from the Perl Programmers Reference Guide, and it's basically the Windows-flavoured version of the whole File::Spec situation. Let's get into it π
π SYNOPSIS π
require File::Spec::Win32; # Done internally by File::Spec if needed
That's it, that's the whole synopsis. You basically never load this yourself β File::Spec pulls it in for you if it needs it, iykyk. π«Ά
πΈ DESCRIPTION πΈ
So here's the tea: for documentation on all the methods this thing provides, go read File::Spec::Unix. This package overrides the implementation of those methods, not the semantics β meaning the vibes stay the same, only the code underneath changes. π
Now, method by method:
π¦ devnull
Returns a string representation of the null device. That's it. That's the whole method. Iconic, honestly. β¨
π tmpdir
Returns a string representation of the first existing directory from this list, in this exact order:
$ENV{TMPDIR}
$ENV{TEMP}
$ENV{TMP}
SYS:/temp
C:\system\temp
C:/temp
/tmp
/
Lowkey important detail: SYS:/temp is the preferred one in Novell NetWare, and C:\system\temp is the one for Symbian β because File::Spec::Win32 is used for those platforms too, not just Windows. π«Ά
β οΈ And if you're running under taint mode, and those environment variables are tainted, they are not used. Safety first, bestie. π₯
π§ case_tolerant
On MSWin32, case-tolerance depends on GetVolumeInformation() $ouFsFlags == FS_CASE_SENSITIVE, which is the thing that indicates case significance when comparing file specifications. Since XP, FS_CASE_SENSITIVE is effectively disabled for the NT subsubsystem.
The original points you at http://cygwin.com/ml/cygwin/2007-07/msg00891.html if you want the lore. π
Default: 1
π file_name_is_absolute
As of right now (yes, really, "as of right now"), this returns:
2if the path is absolute with a volume1if it's absolute with no volume0otherwise
Three whole states, main character energy. π
β catfile
Concatenates one or more directory names and a filename to form a complete path ending with a filename. A little path-building slay. π
π canonpath
No physical check on the filesystem β this is a logical cleanup of a path only. Do not expect it to go touch grass and verify anything actually exists. π
On UNIX it eliminates successive slashes and successive "/.". On Win32 it makes this happen:
dir1\dir2\dir3\..\..\dir4 -> \dir\dir4 and even
dir1\dir2\dir3\...\dir4 -> \dir\dir4
Yes, even the ... one. We love a flexible icon. π¦
π splitpath
($volume,$directories,$file) = File::Spec->splitpath( $path );
($volume,$directories,$file) = File::Spec->splitpath( $path,
$no_file );
Splits a path into its volume, directory, and filename portions. It assumes the last thing is a file path unless the path ends in '\\', '\\.', '\\..', or $no_file is true. On Win32 that means a true $no_file makes this return ( $volume, $path, '' ). π«Ά
Separators accepted are \ and /.
Volumes can be drive letters or UNC sharenames (\\server\share).
And the results can be passed to "catpath" to get back a path equivalent to (usually identical to) the original path. Round trip, bestie. β¨
π splitdir
The opposite of catdir(). Literally the reverse vibe.
@dirs = File::Spec->splitdir( $directories );
Heads up: $directories must be only the directory portion of the path on systems that have the concept of a volume, or that have path syntax that differentiates files from directories. No sneaking filenames in there. π
And 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 this:
File::Spec->splitdir( "/a/b//c/" );
Yields exactly this:
( '', 'a', 'b', '', 'c', '' )
Look at those empty strings. They're supposed to be there. Not a bug. π
πΈ 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. That's the whole note. Protect this knowledge. π₯
π 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. And remember the whole point: this package overrides the implementation of these methods, not the semantics. Same energy, different engine. π
That's the whole page, bestie β no cap, every single flag and path and default is in there. Slay. π
π Signing off from perl v5.42.3, dated 2026-11-03 β see you in the next manpage, mwah π«Άβ¨
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms