#!/usr/bin/perl use strict; $/ = "\0"; opendir PROC,"/proc" or die "cannot open /proc for read: $!\n"; while (defined (my $pid = readdir PROC)) { next unless $pid =~ /^\d+$/; open ENVIRON, " or warn("Could not read ${pid}'s environment: $!\n"), next; close ENVIRON; print "UID ".((stat "/proc/$pid")[4])." is a violator! (pid $pid)\n" if grep /^\.$/, split /:/, $ENV{PATH}; } closedir PROC;