New guy here again. I am trying to list the available UIDs between 200 and 250 on an AIX system. I have a working solution but it's ugly. I am sure there are some of you with Perl PHDs that can suggest a more elegant solution then the one below :) Please let me know what you suggest, thanks!
#!/usr/bin/perl -W my $alluids = "/tmp/uid_list.file"; open (UIDS, ">$alluids") || die "Cannot open file $alluids\n"; while (my @uidlst = getpwent) { print UIDS "$uidlst[2]\n"; } close(UIDS); open (UIDS, "<$alluids") || die "Cannot open file $alluids\n"; while(<UIDS>) { chomp; push(@arr, $_); } close(UIDS); my %hash = map { $_ => 1 } @arr; foreach $i (200..250) { if ( ! defined $hash{$i} ) { print "$i "; } }
In reply to Finding the lowest available UIDs by ronix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |