siddheshsawant has asked for the wisdom of the Perl Monks concerning the following question:
hello monks, I think my previous question was not enough informative to understand so I am asking it in much simpler language.Following are the parts of my code
The initial part was as follows:
#constructor sub new { my ($class) = @_; #my ($proto) = @_; #to make the constructor both class and object method #my $class = ref($proto) || $proto; my $self = { #attributes of object _id => undef, _user_scenario => undef, _result_type => undef, _result_log_link => undef, _not_exposed_reason => undef, _error_excerpt => undef, _triage => undef, }; bless $self, $class; return $self; }
Then I wrote error_excerpt subroutine as follows:
sub error_excerpt { my ($self, $error_excerpt) = @_; return defined($error_excerpt)?$self->{_error_excerpt}:"No Error Excer +pt."; }
When I tried to access the value of error excerpt through subroutine call every time I gets "No Error Excerpt" as an output.Where as I want error excerpt value when it is defined and to print "No Error Excerpt." string when no error_excerpt defiend.I am using strict as well warnings in the code
Kindly let me know where I am doing mistake? Thanks in advance !!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A question on defined loop
by FunkyMonk (Bishop) on Mar 16, 2010 at 16:33 UTC | |
|
Re: A question on defined loop
by almut (Canon) on Mar 16, 2010 at 16:33 UTC | |
| |
|
Re: A question on defined loop
by lostjimmy (Chaplain) on Mar 17, 2010 at 14:25 UTC |