Your code works for me, after I made a simple substitution of opendir(TEXTFILES, ".") || die "Couldn't open the text file directory: $!";
instead of trying to open directory "desktop".. You need to change to the "desktop" directory, because you're doing the test on the current directory..
HTH
The full code that worked for me follows:
use Cwd;
print "Current dir is: ", cwd, "\n";
local $_;
opendir(TEXTFILES, "c:\\CA_LIC") || die "Couldn't open the text file d
+irectory: $!";
@data=readdir(TEXTFILES);
foreach (@data) {
print $_, "\n" if(-d "C:\\CA_LIC\\$_ ");
}
closedir(TEXTFILES);
Update:ZZamboni types faster than I do :o), obviously, he's said what I've tried to say too, better, in fact :o)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.