use strict;
use warnings;
use 5.10.0;
use Devel::Examine::Subs;
my $des = Devel::Examine::Subs->new(file => 'test.pl');
my $subs = $des->objects;
for my $sub (@$subs){
say $sub->name;
say "------";
say $_ for @{ $sub->code };
say "\n";
}
####
use warnings;
use strict;
three(5);
sub three {
return two(shift);
}
sub two {
return one(_helper(shift));
}
sub one {
my $num = calc(shift);
display($num);
}
sub calc {
my $num = shift;
return $num ** 3;
}
sub display {
my $num = shift;
print "$num\n";
}
sub _helper {
my $num = shift;
return ++$num;
}
##
##
spek@scelia ~/scratch $ perl des.pl
display
------
sub display {
my $num = shift;
print "$num\n";
}
two
------
sub two {
return one(_helper(shift));
}
three
------
sub three {
return two(shift);
}
one
------
sub one {
my $num = calc(shift);
display($num);
}
calc
------
sub calc {
my $num = shift;
return $num ** 3;
}
_helper
------
sub _helper {
my $num = shift;
return ++$num;
}