Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Tutorial.pl:
- use lib 'lib';
- use Users;
- my $new_user = new Users("Ben", "1234", 1);
- print("Username: ");
- print($new_user->getName());
- print("\nPassword: ");
- print($new_user->getPass());
- print("\nID: ");
- print($new_user->getID());
- #Users.pm:
- package Users;
- sub new{
- $class = shift;
- $self = {
- #Member Variables:
- username => shift,
- password => shift,
- id => shift
- };
- bless $self, $class;
- return $self;
- }
- sub setName{
- my ($self, $new_name) = @_;
- $self->{username} = $new_name if defined($new_name);
- return $self->{username};
- }
- sub getName{
- my ($self) = @_;
- return $self->{username};
- }
- sub setPass{
- my ($self, $new_pass) = @_;
- $self->{password} = $new_pass if defined($new_pass);
- return $self->{password};
- }
- sub getPass{
- my ($self) = @_;
- return $self->{password};
- }
- sub setID{
- my ($self, $new_ID) = @_;
- $self->{id} = $new_ID if defined($new_ID);
- return $self->{id};
- }
- sub getID{
- my ($self) = @_;
- return $self->{id};
- }
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement