Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: how to get the parent directory name?

by reneeb (Chaplain)
on Dec 08, 2006 at 11:50 UTC ( #588568=note: print w/ replies, xml ) Need Help??


in reply to how to get the parent directory name?

#!/usr/bin/perl use strict; use warnings; use Cwd; print Cwd::realpath('..');


Comment on Re: how to get the parent directory name?
Download Code
Re^2: how to get the parent directory name?
by grinder (Bishop) on Dec 08, 2006 at 13:29 UTC

    Bzzzt! Crash! This is the sound of the cross-platform compatibility police knocking at your door!

    I feel obliged to point out that there is a module that encapsulates the concept of parent directory. Thus your code becomes:

    use strict; use warnings; use Cwd; use File::Spec; print Cwd::realpath(File::Spec->updir);

    When code begins to involve both Cwd and File::Spec, you know it's time to look at Path::Class (see elsewhere in this thread).

    • another intruder with the mooring in the heart of the Perl

Reaped: Re^2: how to get the parent directory name?
by NodeReaper (Curate) on Mar 28, 2014 at 02:29 UTC

Log In?
Username:
Password:

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

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

    Is guessing a good strategy for surviving in the IT business?





    Results (185 votes), past polls