http://qs321.pair.com?node_id=11130754


in reply to Re: File::Find::Rule Help Needed
in thread File::Find::Rule Help Needed

Huck:

That did the trick! I would never have stumbled onto that. Hopefully I will remember that next time. Now onto the grep section.

Thank you very much!

Update: I have no excuse. If I would have consulted my copy of the Perl Cookbook I would have found a recipe in chapter 7 that addressed this issue. File list created and files searched for #includes. Done...

#! /usr/bin/perl # Keithsdr.pl - Script to search for the libraries used by the # C++ source files of the KeithSDR project. # Output to assist with creating documentation. # # James M. Lynes Jr. - KE4MIQ # Created: April 3, 2021 # Last Modified: 4/03/2021 - First working version # use strict; use warnings; use File::Find::Rule; use Data::Dumper; my $input; my $output; open ($output, ">", "keithsdrdoc"); my $dir = ($ENV{HOME}.'/Hamradio/Keithsdr/KEITHSDR-main/SDR_RA8875/'); # # Create a list of C++ files from the SDR_RA8875 directory # my @files = File::Find::Rule->file() ->name('*.cpp', '*.ino') ->maxdepth(1) ->start($dir) ->in($dir); # # Sort the file list # my @sorted = sort @files; @files = @sorted; # # Search each C++ file for library files(#include) # foreach my $file (@files) { print "$file\n"; print $output "$file\n"; open ($input, "<", $file) or die; while (<$input>) { chomp(); if (/#include/) { print "$_\n"; print $output "$_\n"; } } print "\n"; print $output "\n"; } close($input); close($output);

James

There's never enough time to do it right, but always enough time to do it over...