Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^12: Comparing Values PER Sub-folder

by omegaweaponZ (Beadle)
on Sep 05, 2012 at 22:24 UTC ( #991960=note: print w/ replies, xml ) Need Help??


in reply to Re^11: Comparing Values PER Sub-folder
in thread Comparing Values PER Sub-folder

This is fantastic! Although my output looks like its only showing me the final sub-folder's lines. I actually don't need this as each final sub-folder contains just 1 txt file. I want just one level up's directory to check for all sub-directories in that previous directory.

But I'm not seeing this....What am I doing wrong here? $curDir is showing me that final /test/test/BBB directory when I just want /test/test....but I need EVERY sub-folder from the root here of test .... Could a regular expression help out here to filter out everything after a the last / ?

So I'm seeing this:

/test/test1/bb1' do have the same number of lines /test/test1/bb2' do have the same number of lines /test/test1/bb3' do have the same number of lines /test/test1/bb4' do have the same number of lines /test/test1/bb5' do have the same number of lines /test/test1/cc1' do have the same number of lines /test/test2/cc2' do have the same number of lines /test/test2/cc3' do have the same number of lines /test/test2/cc4' do have the same number of lines /test/test2/cc5' do have the same number of lines

So each folder here has 1 txt file. But I want to see this output instead:

/test/test1' do have the same number of lines /test/test2' do not have the same number of lines

Or something of the like. I think I see what's happening that curdir is what's screwing this up. I just need this to be one level up and this would work beautiful


Comment on Re^12: Comparing Values PER Sub-folder
Select or Download Code
Replies are listed 'Best First'.
Re^13: Comparing Values PER Sub-folder
by Kenosis (Priest) on Sep 05, 2012 at 23:07 UTC

    You showed the following example output:

    /test/test1' do have the same number of lines /test/test2' do not have the same number of lines

    Were you looking to have the script count file lines only in those two directories w/o descending into any enclosed directories, or did you want the script to have an output as above even after descending into all enclosed directories?

      Yes, I think....I'm looking for a file count IN the sub-directories OF those directories, so yes. There are no files in test/test1 but there is 1 file in test/test1/A and one in test/test1/B, etc, etc. I'm trying to compare all A, B, C, D from the single test1 subfolder. Confusion at its best!

      So it needs to descend into the enclosed directory of A, B, C, D just to grab those file counts, but it needs to compare and contrast each one as an array so it outputs a single true/false for test/test1 and test/test2, etc. Does that make sense? This is where I'm confused because I'm grabbing the full directory of each file but I just want comparison of its parent folder ONLY per folder.

        Would File::Basename help in this scenario?

        Err, looks like it does actually help...quite a bit! Here is the code I'm using:

        my $basedir = dirname($curDir); my @lines = read_file( $curFile ) ; my $numLines = @lines; push @{ $dirLines{$basedir} }, $numLines;
        From the previous code assigned to this, I can properly get a true/false from an if/else statement. I THINK I might be all set with this now, thank you again for all your help! Very informative and learned a lot

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2015-07-08 05:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls