<?xml version="1.0" encoding="windows-1252"?>
<node id="32335" title="File::Spec" created="2000-09-13 19:35:04" updated="2005-08-11 06:03:46">
<type id="31663">
modulereview</type>
<author id="22609">
tye</author>
<data>
<field name="doctext">
&lt;p&gt;
File::Spec is the long-awaited standard method for doing common tasks with
file names and paths (file specifications or file specs) in a way that is
portable between different operating systems.
&lt;/p&gt;&lt;h2&gt;The Good&lt;/h2&gt;&lt;p&gt;
What it can do:
&lt;ul&gt;&lt;li&gt;&lt;code&gt;$cpath = File::Spec-&gt;canonpath( $path );&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$dirpath = File::Spec-&gt;catdir( $dir1, $dir2, $dir3 );&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$filepath = File::Spec-&gt;catfile( $dir1, $dir2, $dir3, $file );&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$curdir= File::Spec-&gt;curdir();  # "." on Unix&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$nul= File::Spec-&gt;devnull();    # "/dev/null" on Unix&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$root= File::Spec-&gt;rootdir();   # "/" on Unix&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$tmpdir= File::Spec-&gt;tmpdir();  # "/tmp" or $ENV{TMPDIR}, etc.&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$updir= File::Spec-&gt;updir();    # ".." on Unix&lt;/code&gt;
&lt;li&gt;&lt;code&gt;@list= File::Spec-&gt;no_upwards( @list ); # Strips "." and ".."&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$ignore= File::Spec-&gt;case_tolerant();      # Returns false under Unix&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$abs= File::Spec-&gt;file_name_is_absolute($path);&lt;/code&gt;
&lt;li&gt;&lt;code&gt;@path= File::Spec-&gt;path();      # Returns $ENV{PATH} as an array.&lt;/code&gt;
&lt;li&gt;&lt;code&gt;($volume,$dirs,$file)= File::Spec-&gt;splitpath( $path [, $no_file ] );&lt;/code&gt;
&lt;li&gt;&lt;code&gt;@dirs= File::Spec-&gt;splitdir( $dirs );&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$path= File::Spec-&gt;catpath( $vol, $dirs, $file );&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$relpath= File::Spec-&gt;abs2rel( $path [, $base ] );&lt;/code&gt;
&lt;li&gt;&lt;code&gt;$abspath= File::Spec-&gt;rel2abs( $path [, $base ] );&lt;/code&gt;
&lt;/ul&gt;&lt;/p&gt;&lt;h2&gt;The Bad&lt;/h2&gt;&lt;p&gt;
The documentation isn't OS-independant so you have to read the documentation
for &lt;em&gt;each&lt;/em&gt; OS-specific component of File::Spec.  Start with
&lt;code&gt;perldoc File::Spec&lt;/code&gt; then &lt;code&gt;perldoc File::Spec::Unix&lt;/code&gt;
(since that part of the module is the most complete).
&lt;/p&gt;&lt;p&gt;
Not all method are available on all platforms.
&lt;/p&gt;&lt;p&gt;
This module isn't available for even slightly old versions of Perl.  Until and
unless that changes, you may want to back-port the functionality to older
versions of Perl yourself so that your code will still port to different
OSes.
&lt;/ul&gt;&lt;/p&gt;&lt;h2&gt;The Ugly&lt;/h2&gt;&lt;p&gt;
Getting File::Spec functionality for old versions of Perl in a portable, robust
manner.  I hope to add more details on this later.
&lt;/p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- 
&lt;a href="/index.pl?node=tye&amp;lastnode_id=1072"&gt;tye&lt;/a&gt; 
(but my friends call me "Tye")
</field>
<field name="itemdescription">
Portable ways to manipulate file specifications</field>
<field name="usercomment">
Please try to use this module even when &lt;em&gt;you&lt;/em&gt; don't need it</field>
<field name="identifier">
</field>
</data>
</node>
