Nov 21, 2013, 12:27 PM
Post #2 of 4
The only portion that you're doing "correctly" is the test for the number of args passed to the script.
Perl arrays are zero based, so the index of the first element is 0, not 1.
# Sort the uids in ascending order and extract the last element from the array. That does not do any sorting as your comment states. It assigned the 2nd element of @ARGV to the 1st element of @UID.
@UID = $ARGV
#Extract the highest numbered uid listed in the small passwd file. That is not the correct way to run an external command and if it were, it would not save the output of that command. Also, shelling out to the cut command is a funky non perl way of getting the uid.
cut -d:-f3/home/caton03/itec400/homework/ $ARGV;
#Extract the last element from the array. There is no guarantee that the highest numbered uid will be on the last line of the file.
$UID = (pop($UID))+1;
(This post was edited by FishMonger on Nov 21, 2013, 12:27 PM)