Subject: | exists(&subr) new in 5.6.0 |
Date: | Thu, 15 Apr 2010 11:08:54 +1000 |
To: | bug-Perl-MinimumVersion [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
Perl::MinimumVersion might report on the new exists(&subr) support.
I've been using the few lines below
# exists(&subr) new in 5.6.0
#
sub _exists_subr {
my ($pmv) = @_;
$pmv->Document->find_first
(sub {
my ($document, $elem) = @_;
if ($elem->isa('PPI::Token::Word')
&& $elem eq 'exists'
&& is_function_call($elem)
&& ($elem = _symbol_or_list_symbol($elem->snext_sibling))
&& $elem->symbol_type eq '&') {
return 1;
} else {
return 0;
}
});
}
# if $elem is a symbol or a List of a symbol then return that symbol elem,
# otherwise return an empty list
#
sub _symbol_or_list_symbol {
my ($elem) = @_;
if ($elem->isa('PPI::Structure::List')) {
$elem = $elem->schild(0) || return;
$elem->isa('PPI::Statement::Expression') || return;
$elem = $elem->schild(0) || return;
}
$elem->isa('PPI::Token::Symbol') || return;
return $elem;
}