Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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.

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991716]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2018-03-21 04:49 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (263 votes). Check out past polls.