Yes I read readdir, I'm assuming "file testing the return values out of a readdir" is my case of why I can't use it?

Yes, that part, if you're reading from "Foo/" getting a file of "Bar" and then you try to open "Bar" its not going to work as you need to open "Foo/Bar"

used glob like you said. No more errors, but I get no output to STDOUT. I placed "print "$file\n" at the end of my first for loop and I see the files are being iterated through, but the guts of the script where I'm trying to find names and object-groups is not showing any output.

This is where subroutines play important part. Consider this version

usr/bin/perl -- ## 2015-09-21-18:21:28 ## ## ## ## ## ## perltidy -olq -csc -csci=3 -cscl="sub : BEGIN END " -otr -opr -ce +-nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while " -otr + -opr -ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while for " +-otr -opr -ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use Path::Tiny qw/ path /; Main( @ARGV ); exit( 0 ); sub Main { my @files = path( "Configs/" )->children; for my $file ( @files ) { FaFyle( $file ); } } ## end sub Main sub FaFyle { my( $file ) = @_; my $config = ReadConfig( $file ); NaNameConfMod( $config ); ObObjectsConfMod( $config ); } ## end sub FaFyle sub ReadConfig { return [ path( $_[0] )->lines_raw( { chomp => 1 } ) ]; } ## end sub ReadConfig sub NaNamesConfMod { my( $configref ) = @_; my @names = map { /^name \d+\.\d+\.\d+\.\d+ ([A-Za-z0-9-_]+)$/ ? $ +1 : () } @{$configref}; @{$configref} = grep { $_ !~ /^name / } @{$configref}; FaFindCb( sub { print "name $_[0] unused\n" }, \@names, $configref + ); return; } ## end sub NaNamesConfMod sub ObObjectsConfMod { my( $configref ) = @_; my @objects = map { /^(object|object-group) (network|service) ([A-Za-z0-9-_]+)$/ ? $3 : () } @{$configref}; @{$configref} = grep { $_ !~ /^(object|object-group) / } @{$config +ref}; FaFindCb( sub { print "object $_[0] unused\n" }, \@objects, $confi +gref ); return; } ## end sub ObObjectsConfMod sub FaFind { my( $callback, $objects, $config ) = @_; foreach my $object ( @$objects ) { if( !grep { $_ =~ /\Q$object\E/ } @{$config} ) { $callback->( $object ); } } } ## end sub FaFind __END__ __END__

If NaNamesConfMod() isn't working, there is no need to try to debug all the other parts, just  NaNamesConfMod( [  "test data" ] ); sub NaNamesConfMod{... }


In reply to Re^5: Trouble opening and reading file within loop (readdir) by Anonymous Monk
in thread Trouble opening and reading file within loop by H0tc@xe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.