Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^2: File::Find::Rule Help Needed

by jmlynesjr (Deacon)
on Apr 03, 2021 at 01:39 UTC ( #11130754=note: print w/replies, xml ) Need Help??

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


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 # - 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);


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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2022-05-18 18:53 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (71 votes). Check out past polls.