git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@4396
bd8105ee-0ff8-0310-8827-fb3f25b6796d
return ();
}
+# recursively find the last element
+sub last_ppi_element {
+ my ($self, $document, $type) = @_;
+ my $last = $document;
+ while ($last->can('last_element') && defined($last->last_element)) {
+ $last = $last->last_element;
+ return $last if $type && $last->isa($type);
+ }
+ return $last;
+}
+
1;
my $orig = shift;
my ($self, $text, $document) = @_;
- # recursively find the last element
- my $last = $document;
- while ($last->can('last_element') && defined($last->last_element)) {
- $last = $last->last_element;
- }
+ my $last = $self->last_ppi_element($document);
return $orig->(@_)
unless $last->isa('PPI::Token::Word');
my $orig = shift;
my ($self, $text, $document) = @_;
- # recursively find the last element
- my $last = $document;
- while ($last->can('last_element') && defined($last->last_element)) {
- $last = $last->last_element;
- }
+ my $last = $self->last_ppi_element($document);
return $orig->(@_)
unless $last->isa('PPI::Token::Symbol');