Subject: | eliminate nested subs |
The "parse" method has several subroutines defined within its body, like
this:
sub parse
{
my $self = shift;
...
sub pattern_image {
$self->{x] = $_[0];
}
}
This mistake often indicates that the author thought it would mean that
"pattern_image" was only callable from within parse. This is not the
case: it is available globally and at compile-time. Further, it will
be closed over any variables it uses but that are defined externally.
Effectively, this means that a call to MIME::Lite::HTML::pattern will
operate on the last object handled by the parse method, if called
outside of parse.
Nested subs are basically guaranteed to always be a mistake.
--
rjbs