Re: Perl: "find -newer" in nativ

Andreas Fett <[email protected]>
Newsgroups gmane.user-groups.linux.dresden
Message-ID <Y+mAIky9W3RP8/[email protected]>
Hallo,

On Sun, Feb 12, 2023 at 03:48:36PM +0100, Hilmar Preuße wrote:
> 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)

Grüsse
Andreas
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEJ6Jq1qpfVQ9CLff4NMc/tuPtDEAFAmPpgB8ACgkQNMc/tuPt
DEClpQ//VrNPDEs2eDLxVGLh2DcpG/HYLtpqqaL9mHd2Pa91TiEeBMr1z15lbxGj
DIisfDMe47d0TwNqIYutkkqdPf7GmoOm+SUcI4HIXZaPObzwvYxWlDGRNd7infiP
2xG7ocUv/LtawJubjYVqthD4KPzkAeV+nyo4icVuTKrAoqDA1upytrxBAk+tcZ07
3XzjJ1PusrouuLKzIYtpJ5O+mM9V3zr/t90cpKNw3yjoTvQaDaJEbRTUkTogrOY3
Q5WE0ZZ7Fw/5TWuWRtWiwtwIG3LLHMnf9O5hxbTv8UTSk/IyLXiwO6DDOSDE/Yth
2InyZmgoyfbdBYHcuuGwlfNaoL3xLZpUzbHQ0L+lzU0qOm2kDgK5N/XgjFEe6btK
CCKrOZ8IpoGUou4wS2h84Zfy5LrYB5f0GWa2CRL5LUNSYLwyPo4EHdCj3J0njejz
Hyd21t/S8j9bduQTUuBZmWpQ1y7/Tb+nWI9A0ruTFf6qOaL9ODzMm4P+dzmVdvY2
kcMLtRJHn4pU3sKW5WRdGr7Gkqi+4+0f1Q6j7DgyEpk4lYxHeBL7VkgmyF14G9Yw
JXyncHZ4aEwm1nxNA+iU2UT0GfHHB9sMVEQij32DbpZNPhGcOsQD8OanpgpM2hV1
mdSpR6dMWdKe3in+m8EO7XjTERd5jQ8AsEMJBWL+BMKth0vfiI0=
=F3/L
-----END PGP SIGNATURE-----
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.