Hallo,

On Sat, Feb 11, 2023 at 12:50:20PM +0100, Hilmar Preuße wrote:
> Moin,
> 
> voran: ich bin ein absoluter Perl Noob und bin darum wahrscheinlich auch
> zu doof, google zu bedienen (nein bei ChatGPT war ich noch nicht). Ich
> suche in einer Directory Structur eine Liste von Files, die aktueller
> sind als ein Referenz-File. Aktuell mache ich das so:
> 
> my @files1 = `find /path/to/pen8*/pools/*/logf -type f -newer $touchfile
> -name "Psipenta_*.log" 2> /dev/null`;
> 
> In $touchfile findet sich der Name meines Referenz-Files. Ich bin mir
> sicher, das kann man auch nativ in Perl machen. Bitte um Hilfe.

---- snip ----
#!/bin/perl
#
use warnings;
use strict;

use File::stat;
use File::Find;
use Data::Dumper;

my $touchfile = 'ref.txt';

my $touchstat = stat($touchfile) or die "No $touchfile: $!";

my @files = ();
my $wanted = sub {
        my $stat = stat($_);
        push @files, $File::Find::name if -f $stat && $stat->mtime > 
$touchstat->mtime; # TODO check name
};

find($wanted, glob("/path/to/pen8*/pools/*/logf"));

print Dumper(@files);
---- snip ----

Den Match für den Filenamen bekommste selber hin :-)

https://perldoc.perl.org/File::Find
https://perldoc.perl.org/perlrequick

viel Spass.

Grüsse
Andreas



Attachment: signature.asc
Description: PGP signature

Antwort per Email an