in reply to Re^2: Question on XML output using Perl
in thread Question on XML output using Perl
#!/usr/bin/perl use strict; use warnings; my $e = Error::Excerpt->new; print $e->get_error_excerpt, qq{\n}; $e->set_error_excerpt(q{We have an error}); print $e->get_error_excerpt, qq{\n}; package Error::Excerpt; sub new { my $class = shift; my $self = { _error_excerpt => undef, }; bless ($self, $class); return $self; } sub set_error_excerpt{ my $self = shift; my $ee = shift; $self->{_error_excerpt} = $ee; } sub get_error_excerpt{ my $self = shift; my $ee = $self->{_error_excerpt}; return $ee?$ee:q{No Error Excerpt}; }
imo, dividing up the task using getters and setters is often worth considering. Add error checking as appropriate.No Error Excerpt We have an error
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Question on XML output using Perl
by siddheshsawant (Sexton) on Mar 16, 2010 at 16:30 UTC |