C:\>perldoc File::Basename
NAME
fileparse - split a pathname into pieces
basename - extract just the filename from a path
dirname - extract just the directory from a path
SYNOPSIS
use File::Basename;
($name,$path,$suffix) = fileparse($fullname,@suffixlist)
fileparse_set_fstype($os_string);
$basename = basename($fullname,@suffixlist);
$dirname = dirname($fullname);
($name,$path,$suffix) =
fileparse("lib/File/Basename.pm","\.pm");
fileparse_set_fstype("VMS");
$basename = basename("lib/File/Basename.pm",".pm");
$dirname = dirname("lib/File/Basename.pm");
DESCRIPTION
These routines allow you to parse file specifications into useful
pieces
using the syntax of different operating systems.
fileparse_set_fstype
You select the syntax via the routine fileparse_set_fstype().
If the argument passed to it contains one of the substrings
"VMS",
"MSDOS", "MacOS", "AmigaOS" or "MSWin32", the file specification
syntax of that operating system is used in future calls to
fileparse(), basename(), and dirname(). If it contains none of
these
substrings, Unix syntax is used. This pattern matching is
case-insensitive. If you've selected VMS syntax, and the file
specification you pass to one of these routines contains a "/",
they
assume you are using Unix emulation and apply the Unix syntax
rules
instead, for that function call only.
If the argument passed to it contains one of the substrings
"VMS",
"MSDOS", "MacOS", "AmigaOS", "os2", "MSWin32" or "RISCOS", then
the
pattern matching for suffix removal is performed without regard
for
case, since those systems are not case-sensitive when opening
existing files (though some of them preserve case on file
creation).
If you haven't called fileparse_set_fstype(), the syntax is
chosen
by examining the builtin variable "$^O" according to these
rules.
fileparse
The fileparse() routine divides a file specification into three
parts: a leading path, a file name, and a suffix. The path
contains
everything up to and including the last directory separator in
the
input file specification. The remainder of the input file
specification is then divided into name and suffix based on the
optional patterns you specify in "@suffixlist". Each element of
this
list is interpreted as a regular expression, and is matched
against
the end of name. If this succeeds, the matching portion of name
is
removed and prepended to suffix. By proper use of "@suffixlist",
you
can remove file types or versions for examination.
You are guaranteed that if you concatenate path, name, and
suffix
-- More --
> -----Original Message-----
> From: Brian Ling [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 21, 2003 10:25 AM
> To: [EMAIL PROTECTED]
> Subject: Path to script
>
>
> Hi all,
>
> I have the following bit of code that works out the directory
> path to the currently executing script.
>
> My $path = $0;
> $path =~ s#(^/.+/).+$#$1# ;
>
> This works but doesn't make me happy, is there a better way?
>
> Thanks
>
> Brian
>
>
>
> BBCi at http://www.bbc.co.uk/
>
> This e-mail (and any attachments) is confidential and may contain
> personal views which are not the views of the BBC unless specifically
> stated.
> If you have received it in error, please delete it from your
> system, do
> not use, copy or disclose the information in any way nor act in
> reliance on it and notify the sender immediately. Please note
> that the
> BBC monitors e-mails sent or received. Further communication will
> signify your consent to this.
>
>
**** DISCLAIMER ****
"This e-mail and any attachment thereto may contain information which is confidential
and/or protected by intellectual property rights and are intended for the sole use of
the recipient(s) named above.
Any use of the information contained herein (including, but not limited to, total or
partial reproduction, communication or distribution in any form) by other persons than
the designated recipient(s) is prohibited.
If you have received this e-mail in error, please notify the sender either by
telephone or by e-mail and delete the material from any computer".
Thank you for your cooperation.
For further information about Proximus mobile phone services please see our website at
http://www.proximus.be or refer to any Proximus agent.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]