> > > #!/usr/bin/perl -w > > system("/usr/bin/clear"); > @arg1 = qw( > mail > sysquota > root > nobody > smmsp > daemon > testing > );
When you are doing does it exist operation a hash would be a better data structure than an array. > > > unless (open(RQUOTA,"/usr/sbin/repquota -a |")) { > print("Unable to open repquota file:\n"); > } else { > if (-e "/tmp/stat.tmp") { > unlink("/tmp/stat.tmp"); > } > print("Users Without Quotas * * * *\n\n"); > while (<RQUOTA>) { > if (/\s0\s{7}0\s{1,}/) { > for ( $i = 0; $i <=6; $i++ ) { > s/\b$arg1[$i]\b\s{0,}\-\-\s{0,}[0-9]{1,}.*$//g; > } > if (/^[a-zA-Z0-9]/) { > print("$_"); > } > if (/(\w+)/) { > unless (open(NQUOTA,">>/tmp/stat.tmp")) { > print("Unable to open /tmp/stat.tmp file:\n"); > } else { > print(NQUOTA "$1\n"); > } > } > } > } > > print("\n"); > close(NQUOTA); > close(RQUOTA); > } I must confess that I did not analyse your code, this is how I would do it #!/usr/bin/perl -w use strict; my %quotaless_users; # As I mentioned before a hash is more suited for 'does it exist' operation open (RQUOTA, "/usr/sbin/repquota -a |") or die "$0 : Unable to execute /usr/sbin/repquota : $!\n"; while (<RQUOTA>) { my $user = (split)[0]; # The lines with the user quota information starts with the username. # Use the default behaviour of split (splits on white space after ignoring leading white spaces) # Element 0 is your username (perldoc -f split) $quotaless_users{$user}++ if (defined (getpwnam ($user))); # Use getpwnam (perldoc -f getpwnam) to check if it is a valid user # Used in a scalar context it returns the uid, if user does not exist returns undef } # Loop through your user list and print the quotaless users foreach ("mail", "sysquota", "root", "nobody", "smmsp", "daemon", "testing") { print "quotaless user $_\n" unless ($quotaless_users{$_}); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]