Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: Comparing Values PER Sub-folder

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


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

Good call about untie. But even if I use slurp I'm still not recieving any print return results.

find(\&countLines, $dir); sub countLines { /\.txt$/ or return; my $completePath = $File::Find::name; my $curDir = $File::Find::dir; my $curFile = $_; my @lines = read_file( $curFile ) ; my $numLines = @lines; print "Cur dir: $curDir; Cur file: $curFile; Num Lines: $numLines +\n";

Is this definitely finding every .txt file in ALL sub-directories? I don't understand why it wouldn't even print a current directory or current file unless that .txt parameter is not working and its finding 0 files.


Comment on Re^4: Comparing Values PER Sub-folder
Download Code
Re^5: Comparing Values PER Sub-folder
by Kenosis (Priest) on Sep 05, 2012 at 02:12 UTC

    Yes, provided that the top dir contains *.txt files. You can try commenting out /\.txt$/ or return;, so all files are displayed. Another option is to initialize $dir with the complete path to the 'top' directory you want File::Find to traverse, in case '.' may not be working.

      Looks like I had some type of perl package mis-match. I was attempting to initialize File::Find::Rule on a prior test, which conflicted with something. I re-arranged something also in a different sub and it seems to be working just fine now. I think slurp is a good way to grab this, by setting these to a variable I think a simple comparison of directory to file lines should work well, but I will post again if something else seems to go astray. Thank you for your help!

        Great, omegaweaponZ--and you're very welcome!! Am glad you got it working!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-10-26 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (151 votes), past polls