#!/usr/bin/perl -w ## ## DETERMINE NEXT UID THAT IS UNIQUE FOR NEXT USER ACCOUNT CREATION. ## use strict; my $file = "/etc/passwd"; my @UID; my $DEBUG="0"; open(FILE, "<$file") or die ("UNABLE TO OPEN $file FOR READING: $!\n"); while(< FILE>){ my($user,$x,$uid,@rest) = split(/:/,$_); push(@UID, $uid); } close(FILE); print "ARRAY SIZE: $#UID\n"; my $cnt = '0'; foreach (sort { $a <=> $b } @UID) { if($DEBUG == '1') { print "UID= $_\n"; } $cnt+=1; if($cnt == $#UID) { if($DEBUG == '1') { print "UID: $_\n"; } my $nextuid=$_ + 2; print "NEXT UID: $nextuid\n"; } }