Guest User

Untitled

a guest
Sep 27th, 2017
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. package functs_skeleton;
  2.  
  3. use strict;
  4.  
  5. # Export functions--copy next 4 lines verbatim
  6. use Exporter;
  7. use vars qw (@ISA @EXPORT);
  8. @ISA = qw(Exporter);
  9. @EXPORT = ("add_user", "edit_user", "delete_user", "print_list");
  10.  
  11.  
  12. #################### add_user function ####################
  13. sub add_user {
  14. my $param = shift;
  15. my %local_hash = %$param;
  16.  
  17. #prompt/chomp for username & password
  18. print "...";
  19. my $username = <>;
  20. chomp($username);
  21. my $password = <>;
  22. chomp($password);
  23.  
  24. # strip off special chars from username (ref asmt sheet)
  25. # convert username to lowercase (ref asmt sheet)
  26. # strip off apostrophe from password (ref asmt sheet)
  27. # encrypt password
  28.  
  29. # check if username already exists & if so exit, else assign password as value to the hash referenced by username as the key
  30.  
  31. # assign password as value to the hash referenced by username
  32.  
  33. return %local_hash;
  34. }
  35.  
  36.  
  37.  
  38. #################### edit_user function ####################
  39. sub edit_user {
  40. my $param = shift;
  41. my %local_hash = %$param;
  42.  
  43. # prompt/chomp for username
  44. # strip off special chars from username (ref asmt sheet)
  45. # convert username to lowercase (ref asmt sheet)
  46. # check if username DOESNT already exists & if NOT so exit
  47.  
  48. # prompt/chomp for current password
  49. # strip off apostrophe from password (ref asmt sheet)
  50. # encrypt password
  51. # check if password DOESNT exist & if NOT so exit
  52.  
  53. #prompt/chomp for new password
  54. # strip off apostrophe from password (ref asmt sheet)
  55.  
  56. # assign password as value to the hash referenced by username as the key
  57.  
  58. return %local_hash;
  59. }
  60.  
  61.  
  62.  
  63. #################### delete_user function ####################
  64. sub delete_user {
  65. my $param = shift;
  66. my %local_hash = %$param;
  67.  
  68. # prompt/chomp for username
  69. # strip off special chars from username (ref asmt sheet)
  70. # convert username to lowercase (ref asmt sheet)
  71. # check if username DOESNT already exists & if NOT so exit
  72.  
  73. # prompt/chomp for password
  74. # strip off apostrophe from password (ref asmt sheet)
  75. # encrypt password
  76. # check if password DOESNT exist & if NOT so exit
  77.  
  78. #delete key from hash (ref slides)
  79. delete $local_hash{$param};
  80. return %local_hash;
  81. }
  82.  
  83.  
  84. #################### print_list function ####################
  85. sub print_list {
  86. my $param = shift;
  87. my %local_hash = %$param;
  88.  
  89. # print out to the screen each key & value pair from hash (ref .pl file when the hash is wriiten to a file)
  90.  
  91. return %local_hash;
  92. }
  93.  
  94.  
  95. 1;
Add Comment
Please, Sign In to add comment