Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package functs_skeleton;
- use strict;
- # Export functions--copy next 4 lines verbatim
- use Exporter;
- use vars qw (@ISA @EXPORT);
- @ISA = qw(Exporter);
- @EXPORT = ("add_user", "edit_user", "delete_user", "print_list");
- #################### add_user function ####################
- sub add_user {
- my $param = shift;
- my %local_hash = %$param;
- #prompt/chomp for username & password
- print "...";
- my $username = <>;
- chomp($username);
- my $password = <>;
- chomp($password);
- # strip off special chars from username (ref asmt sheet)
- # convert username to lowercase (ref asmt sheet)
- # strip off apostrophe from password (ref asmt sheet)
- # encrypt password
- # check if username already exists & if so exit, else assign password as value to the hash referenced by username as the key
- # assign password as value to the hash referenced by username
- return %local_hash;
- }
- #################### edit_user function ####################
- sub edit_user {
- my $param = shift;
- my %local_hash = %$param;
- # prompt/chomp for username
- # strip off special chars from username (ref asmt sheet)
- # convert username to lowercase (ref asmt sheet)
- # check if username DOESNT already exists & if NOT so exit
- # prompt/chomp for current password
- # strip off apostrophe from password (ref asmt sheet)
- # encrypt password
- # check if password DOESNT exist & if NOT so exit
- #prompt/chomp for new password
- # strip off apostrophe from password (ref asmt sheet)
- # assign password as value to the hash referenced by username as the key
- return %local_hash;
- }
- #################### delete_user function ####################
- sub delete_user {
- my $param = shift;
- my %local_hash = %$param;
- # prompt/chomp for username
- # strip off special chars from username (ref asmt sheet)
- # convert username to lowercase (ref asmt sheet)
- # check if username DOESNT already exists & if NOT so exit
- # prompt/chomp for password
- # strip off apostrophe from password (ref asmt sheet)
- # encrypt password
- # check if password DOESNT exist & if NOT so exit
- #delete key from hash (ref slides)
- delete $local_hash{$param};
- return %local_hash;
- }
- #################### print_list function ####################
- sub print_list {
- my $param = shift;
- my %local_hash = %$param;
- # print out to the screen each key & value pair from hash (ref .pl file when the hash is wriiten to a file)
- return %local_hash;
- }
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement