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...
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|