Re: Perl: "find -newer" in nativ

Hilmar Preuße <[email protected]>
Newsgroups gmane.user-groups.linux.dresden
Organization Hilmar Preuße Inc.
Message-ID <[email protected]>
On 2/13/23 01:11, Andreas Fett wrote:
> On Sun, Feb 12, 2023 at 03:48:36PM +0100, Hilmar Preuße wrote:

Hallo,

>> my $wanted = sub {
>>          my $stat = stat($_);
>>          return unless -f $stat;
>>          return unless $stat->mtime > $touchstat->mtime;
>>          return unless /$filePattern/;
>>          push @files, $File::Find::name;
>> };
>>
>> find($wanted, glob("/var/log/icinga/logs"));
>
> Eine Anmerkung noch. Es ist eventuell effizienter, wenn Du den Check
> auf den Filename vor das stat() legst. Ich bin mir nicht 100% sicher,
> ob das im konkreten Anwendungsfall wirklich nen Unterschied macht, aber
> solche syscalls grad bei Filesystemzeugs sind in Perl tendenziell teuer.
> (in C würd ich das definitiv davor legen)
>
OK, danke für Deinen Input; habe es jetzt so geändert. An der Laufzeit
des Skriptes ändert sich dadurch aber wenig, denn die echten Zeitfresser
sind weiter hinten.

Hilmar
--
Testmail
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.