"...loop through multiple directories full of logs files..."

Finding them might be an option:

#!/usr/bin/env perl use strict; use warnings; use File::Find::Rule; use Data::Dump; use Try::Tiny; use feature qw(say); my @dirs = qw(./logs); my @files = File::Find::Rule->file()->name('*.log')->exec( \&acme )->i +n(@dirs); dd \@files; sub acme { say shift; try { ...; } catch { print $_; }; } __END__ karls-mac-mini:dotowwxo karl$ ./dotowwxo.pl dotowwxo1.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo10.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo2.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo3.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo4.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo5.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo6.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo7.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo8.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo9.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo1.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo10.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo2.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo3.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo4.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo5.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo6.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo7.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo8.log Unimplemented at ./dotowwxo.pl line 19. dotowwxo9.log Unimplemented at ./dotowwxo.pl line 19. [ "logs/bar/dotowwxo1.log", "logs/bar/dotowwxo10.log", "logs/bar/dotowwxo2.log", "logs/bar/dotowwxo3.log", "logs/bar/dotowwxo4.log", "logs/bar/dotowwxo5.log", "logs/bar/dotowwxo6.log", "logs/bar/dotowwxo7.log", "logs/bar/dotowwxo8.log", "logs/bar/dotowwxo9.log", "logs/foo/dotowwxo1.log", "logs/foo/dotowwxo10.log", "logs/foo/dotowwxo2.log", "logs/foo/dotowwxo3.log", "logs/foo/dotowwxo4.log", "logs/foo/dotowwxo5.log", "logs/foo/dotowwxo6.log", "logs/foo/dotowwxo7.log", "logs/foo/dotowwxo8.log", "logs/foo/dotowwxo9.log", ]

Please note also that File::Find::Rule comes also with a built-in grep.

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help


In reply to Re: Looping through multiple directories by karlgoethebier
in thread Looping through multiple directories by dotowwxo

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.