How to get current directory path

M

moonhkt

Hi All

How to get current directory path ?

e.g c:\temp

how to using perl get current directory path ? "c:\temp"


moonhkt
 
A

Andrew DeFaria

body { font: Helvetica, Arial, sans-serif; } p { font: Helvetica, Arial, sans-serif; } ..standout { font-family: verdana, arial, sans-serif; font-size: 12px; color: #993333; line-height: 13px; font-weight: bold; margin-bottom: 10px; } ..code { border-top: 1px solid #ddd; border-left: 1px solid #ddd; border-right: 2px solid #000; border-bottom: 2px solid #000; padding: 10px; margin-top: 5px; margin-left: 5%; margin-right: 5%; background: #ffffea; color: black; -moz-border-radius: 10px; } ..codedark { border-top: 10px solid #03f; border-left: 1px solid #ddd; border-right: 2px solid grey; border-bottom: 2px solid grey; padding: 10px; margin-top: 5px; margin-left: 5%; margin-right: 5%; background: black; color: yellow; -moz-border-radius: 10px; } #code { color: black; font-size: 14px; font-family: courier; padding-left: 5px; } #line-number { color: #804000; font-family: Arial; font-size: 14px; padding-right: 5px; border-right: 1px dotted #804000; } blockquote[type=cite] { padding: 0em .5em .5em .5em !important; border-right: 2px solid blue !important; border-left: 2px solid blue !important; } blockquote[type=cite] blockquote[type=cite] { border-right: 2px solid maroon !important; border-left: 2px solid maroon !important; } blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] { border-right: 2px solid teal !important; border-left: 2px solid teal !important; } blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] { border-right: 2px solid purple !important; border-left: 2px solid purple !important; } blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] { border-right: 2px solid green !important; border-left: 2px solid green !important; } moonhkt wrote: Hi All

How to get current directory path ?

e.g c:\temp

how to using perl get current directory path ? "c:\temp"
Have you tried http://perldoc.perl.org/Cwd.html ? It's a wonderfully enlightening site. I suggest in the future you use it to answer such simple questions.
 
R

Randal L. Schwartz

Jürgen> perldoc Cwd

Jürgen> I think it's a standard module, but I may be wrong.

Yes, been standard for a long time. A *long* time. Perl 5.0, I think.
 
J

Justin C

Hi All

How to get current directory path ?

e.g c:\temp

how to using perl get current directory path ? "c:\temp"

The Current Working Directory?...

perldoc Cwd
 
S

sln

Hi All

How to get current directory path ?

e.g c:\temp

how to using perl get current directory path ? "c:\temp"


moonhkt

use strict;
use warnings;
use Cwd;
use File::Spec::Functions ':ALL';

my $path = lc rel2abs('c:\\temp\\');

print "Are we in this direcoty?\n\t$path\n";

if (chdir($path) and lc rel2abs(cwd()) eq $path) {
print "Yes indeed, the current directory is:\n\t$path\n";
} else {
print "Nope, doesen't appear so..\n";
}

-sln
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top