#! /usr/bin/perl -W use strict; use 5.010; my %accounts = (tom => "BigApple"); my %types = (tom => "admin"); my $choice; my ($userID, $passwd, $type); my @userID = $userID; my $menu = <); if ($choice == 1){ print "Enter your userID: "; chomp ($userID = ); print "Enter your password: "; chomp ($passwd = ); if (exists $accounts{$userID}) { print "Duplicate user id, try again later" }else { print "Enter the account type, admin (or regular): "; chomp ($type = ); $accounts{$userID} = $passwd; $types{$userID} = $type; print "Account was successfully created \n"; } } elsif ($choice == 4){ # sort the users in descending order foreach $userID (reverse sort keys %accounts) { # print out login names 3 per line @keys = keys %accounts; for (my $counter = 1; $counter <= @keys; $counter++) { print "$userID\t"; print "\n" if $counter % 3 == 0; } } } else { print "Invalid choice, TRY AGAIN!\n"; } }