Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: change the end of a path inside file

by jwest (Friar)
on Jul 17, 2002 at 19:13 UTC ( #182557=note: print w/ replies, xml ) Need Help??


in reply to change the end of a path inside file

use File::Spec.

The splitpath method will seperate the file name from the directory. Take the file it returns, decrement it, and use the catpath method to rebuild the path.

This solution will be portable across most systems.

use File::Spec; my ($volume, $path, $file) = File::Spec->catpath($path_to_decrement); --$file; my $newpath = File::Spec->catpath($volume, $path, $file);
This way is a little pedestrian, but it gets the job done.

Hope this helps!

--jwest


-><- -><- -><- -><- -><-
All things are Perfect
    To every last Flaw
    And bound in accord
         With Eris's Law
 - HBT; The Book of Advice, 1:7


Comment on Re: change the end of a path inside file
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://182557]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2014-07-25 05:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (167 votes), past polls