OK version x.3 Please just change these lines to make it work. The calling program test.pl fails on the assignment line:
Will do, but I'm not 100% sure you're listening to the suggestions we give.
Bareword "fname" not allowed while "strict subs" in use at utest line 8.
Bareword "lname" not allowed while "strict subs" in use at utest line 9.
Bareword "fname" not allowed while "strict subs" in use at utest line 12.
Execution of test.pl aborted due to compilation errors.
Nice to see the errors. I see you already figured them out though.
test.pl ------- #!/usr/bin/perl
use strict;
use warnings;
use UserInfo;
my $user = UserInfo->new(f_name => 'bob', l_name => 'Bingham');
#change name
$user->f_name('robert');
print $user->full_name(), "\n";
UserInfo.pm ----------- #!/usr/bin/perl package UserInfo;
use strict;
use warnings;
sub new { my $class = shift;
my $self = { f_name => 'bob', l_name => 'Bingham', @_ };
return bless $self, $class; }
sub full_name { my $self = shift;
return $self->{f_name} . ' ' . $self->{l_name};
}
sub f_name { my $self = shift; $self->{f_name} = shift if @_; return $self->{f_name}; }
sub l_name { my $self = shift; $self->{l_name} = shift if @_; return $self->{l_name}; }
1;
Good luck.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]