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:

  • 2 if the path is absolute with a volume
  • 1 if it's absolute with no volume
  • 0 otherwise

πŸ”₯ 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 (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