ronix has asked for the wisdom of the Perl Monks concerning the following question:
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 "; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finding the lowest available UIDs
by Limbic~Region (Chancellor) on Nov 11, 2008 at 21:02 UTC | |
|
Re: Finding the lowest available UIDs
by JavaFan (Canon) on Nov 11, 2008 at 20:57 UTC | |
by Your Mother (Archbishop) on Nov 11, 2008 at 22:58 UTC | |
by JavaFan (Canon) on Nov 12, 2008 at 12:11 UTC | |
by Your Mother (Archbishop) on Nov 12, 2008 at 17:24 UTC | |
|
Re: Finding the lowest available UIDs
by ronix (Novice) on Nov 11, 2008 at 21:13 UTC |