dear monks,
i want to list the directories after checking if its available or not. example, "/home/folders/" has directories namely 'case1','case2','case3','case4', so on..... under each case, there are many directories, but i want to check for the availabilities of only 3 directories namely "SORTED", "CLEANED" and "PROCEED".
The way i want to print the results is: (assuming that the "no"s are the directories which are absent in few of the cases)....
CASENAME SORTED CLEANED PROCEED
case1 yes no no
case2 yes yes yes
case3 no yes yes
case4 no no no
What i have done so far is: (but am not getting the desired results)
#!/usr/bin/perl
open(FILE,'>out.txt') or die $!;
if($one eq "option1"){
opendir(DIR,"/home/folders/") or die "can not open directory";
foreach my $line (sort grep !/^\./, readdir DIR){
print FILE "$line|";
opendir(DIR1,"/home/folders/$line");
foreach my $line1 (sort grep !/^\./, readdir DIR1){
if($line1=~/sorted/ && $line1=~/^\w/){print FILE "Yes|";}
elsif($line1=~/cleaned/ && $line1=~/^\w/){print FILE "Yes|";}
elsif($line1=~/proceed/ && $line1=~/^\w/){print FILE "Yes|";}
}
print FILE "\n";
}
}
close (FILE);
open(FILE1,'out.txt') or die $!;
print "CASENAME SORTED CLEANED PROCEED";
while($ln=<FILE1>){
($directory,$subdir1,$subdir2,$subdir3)=split(/\|/,$ln);
print "\n$directory\t";
if($subdir1 ne "Yes"){print "No\t";}else{print "Yes\t";}
if($subdir2 ne "Yes"){print "No\t";}else{print "Yes\t";}
if($subdir3 ne "Yes"){print "No\t";}else{print "Yes\t";}
}
close(FILE1);
unlink("out.txt");
Thank u :)
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.