Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Current Directory

by fizbin (Chaplain)
on Sep 14, 2005 at 14:20 UTC ( [id://491880]=note: print w/replies, xml ) Need Help??


in reply to Current Directory

It took me three times reading that to figure out what you were trying to say.

In any case, the general question you ask about finding, given a directory, its parent directory, is best done through using File::Spec. Actually, though, if you're going to be using it anyway, you probably want to use it in the snippet of code you already posted. This code gets you $currdir as before, its parent, and the parent of that:

BEGIN { use File::Spec; use strict; my ($currdir, $currdirp, $currdirpp); my ($zvolume, $zdirs, $zfile) = File::Spec->splitpath( File::Spec->rel2abs($0) +); my @dirs = File::Spec->splitdir($zdirs); $currdir = File::Spec->catpath($zvolume, $zdirs, ''); pop @dirs; $currdirp = File::Spec->catpath($zvolume, File::Spec->catdir(@dirs), + ''); pop @dirs; $currdirpp = File::Spec->catpath($zvolume, File::Spec->catdir(@dirs) +, ''); # Now do something with those variables. }
--
@/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 05:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found