perl -MB::Deparse \
-MHTML::TableExtract \
-le 'print B::Deparse->new->coderef2text(\&HTML::TableExtract::TableState::_taste_text)'
{
package HTML::TableExtract::TableState;
my($self, $text) = @_;
my $sc = $self->_skew;
if ($self->_terminus_trigger and $self->_column_wanted or $$self{'umbrella'}) {
if (defined $text) {
print STDERR "Add text '$text'\n" if $$self{'debug'} > 3;
$self->_add_text($text, $sc);
}
}
if (defined $text and $self->_any_headers and not $self->_any_htrigger) {
$self->_htxt($text);
}
1;
}
####
$source_code =~ s/(\$self.*)$/$1
print "skew: ".\$self->_skew."\\n"
. "_terminus_trigger: ".\$self->_terminus_trigger."\\n"
. "_column_wanted: ".\$self->_column_wanted."\\n"
. "umbrella: \$\$self{'umbrella'}\\n"
. "text: q[\$text]\\n";\n/ or die "Source patch failed";
####
*HTML::TableExtract::TableState::_taste_text =
eval "sub { package Package::Name; $source_code };" or die "Eval of \$source_code failed: $@";
####
use B::Deparse ();
{ # Fetch the original source code
my $source_code = B::Deparse->new->coderef2text( \&HTML::TableExtract::TableState::_taste_text );
# Alter the source to include error trapping and the diagnostics
$source_code = 'eval { ' . $source_code . ' }; print STDERR $@ if $@; die $@;';
$source_code =~ s/(\$self.*)$/$1
print "skew: ".\$self->_skew."\\n"
. "_terminus_trigger: ".\$self->_terminus_trigger."\\n"
. "_column_wanted: ".\$self->_column_wanted."\\n"
. "umbrella: \$\$self{'umbrella'}\\n"
. "text: q[\$text]\\n";\n/ or die "Source patch failed";
# (updated - added a package declaration per 'theorbtwo')
# Create and assign the new method into place.
*HTML::TableExtract::TableState::_taste_test =
eval "sub { package HTML::TableExtract::TableState; $source_code; };"
or die "Eval of \$source_code failed: $@\n$source_code";
}