Perl-Python-a-Day: split a file full path

Dr.Ruud rvtol+news at isolution.nl
Mon Oct 17 07:50:47 EDT 2005


Xah Lee:

> In Perl, spliting a full path into parts is done like this:

And then follows Perl-code that only works with an optional .html
"extension",
which is similar to the code in the File::Basename description.
http://www.perl.com/doc/manual/html/lib/File/Basename.html


It is best practice to derive and store the normalized (or absolute)
path, because relative paths can get loose so will get loose.


Consider this:

  $myPath = './example/basename.ext';


and this:

  $myPath = './example/filename.1.23.45-beta';


and this:

  $myPath = 'x:.\example\basename.ext';


(some platforms have a wd per device)


-- 
Affijn, Ruud

"Gewoon is een tijger."




More information about the Python-list mailing list