File - Module for file manipulation
use PIRL::File;
File::Filename_Extension ($filename) File::Make_Path ($pathname)
This module contains file manipulation functions.
Returns a file extension from a filename string, where a file extension is the last sequence of alphanumeric characters in the filename preceded by one dot ('.') character.
$filename - The name of the file, which can be a full pathname.
The extension of the provided filename, or undef if no extension is found.
Filename_Extension ("/tmp/file.txt")
Returns the string "txt".
Creates all segments of a directory pathname if they don't already exist.
Attempting to create directories where a normal file already exists will fail. For example, calling Make_Path ("/tmp/test/foo") when /tmp/test is an existing normal file (not a directory) will result in the message "A directory is needed where the /tmp/test file exists." being printed to STDERR. The existing file will not be affected and the return value will be false (0). The /tmp directory will have been created or will have already been present.
Attempting to create a directory in a parent directory where the user does not have write permission will fail. For example, calling Make_Path ("/my_dir") without write permission for the root directory ("/") will result in the message "Unable to make the /my_dir directory.", followed by the reason why the directory could not be created - in this case "Permission denied" - being printed to STDERR. If there are directory segments in the pathname before the write locked segment is encountered, they will have been created or will have already been present.
$pathname - The directory pathname, absolute or relative, to be created
true (1) on success, or false (0) if there was a problem.
Make_Path ("/tmp/dir1/dir2/");
Creates the directory dir1 under /tmp, assuming /tmp already exists (which is usually the case on Unix systems), and then the directory dir2 under dir1.
Drew Davidson and Bradford Castalia, UA/PIRL
Copyright (C) 2005, 2006 Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1.4 2006/03/31 01:24:55