Solved

directory handling on NT

Posted on 1998-10-01
8
146 Views
Last Modified: 2010-03-05
2 questions:
first, how do you determine the existance of a named directory on NT?  -e $fn doesn't work.
second, can mkdir() or another method be used to create a directory other than in the current one (like a\b\c for example)?
0
Comment
Question by:glow060197
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 5

Expert Comment

by:b2pi
ID: 1205069
I don't believe either of these is NT specific

-d will tell you if a directory exists, or if a file is a directory
(note that even on unix, -f $dir will return false if $dir is a
directory).

mkdir(/this/is/an/odd/path) will work if /this/is/an/odd is a
directory, or, you can use

use File::Path;
mkpath('/this/is/an/odd/path',0,777);

which will make whatever part of the path needs to be made.


0
 

Author Comment

by:glow060197
ID: 1205070
actually on NT to get directory entry attributes (e.g. file ? directory? hidden? ...) you must use Win32::File::getAttributes()  or something similar (i'm away from my notes..) but that doesn't allow for checking *existence* which is what i'm looking for.  you're halfway there..i'll give you the points if you get this.  thanks.  

what i don't understand is why they couldn't have made the -x type commands work on NT if you can do it anyways.  is the Win32 library ("module") somehow "non-standard", or what?
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1205071
Have you actually TRIED using -d?  Or are you using ActiveWare?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:glow060197
ID: 1205072
actually I am using ActiveWare...I don't know any better to use.
I actually tried using -f and -d though.  what perl should i obtain?  does gnu have one for Windows?
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1205073
Yup.  If you download the standard distribution, it compiles fine, and
(I believe) standard file operators work.
0
 

Author Comment

by:glow060197
ID: 1205074
alright.  if you want the points, though you need to submit another 'answer'.  
thanks a lot.
0
 
LVL 5

Accepted Solution

by:
b2pi earned 100 total points
ID: 1205075
You are sure that the code

if (-f '/temp') {
   print "How did I get here?\n";
} else {
   print "Yup, -f returns 0 on directories\n";
}

if (-d '/temp') {
    print "Yup, -d does work\n";
} else {
    print "Oh, no, Mr. Bill!!!\n";
}



doesn't do what it should on active ware?
0
 

Author Comment

by:glow060197
ID: 1205076
those commands didn't seem to work, no.  but i'll try your code tomorrow and see how it does.

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Removing file extension within a file. 4 103
Port 80 requests 16 102
Perl string replace for refred url 9 70
read an xml file in perl 2 65
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question