develooper Front page | perl.perl5.porters | Postings from December 2001

sub inconveniences

Wolfgang Laun
December 21, 2001 07:24
sub inconveniences
Message ID:
Maybe these two questions are related, maybe not.

Question 1:

$ perl  -MO=Xref <<XXX
> sub p{
>     print "\n";
>     print "\n";
> }

results in:

    Package main
      &p                s4

The line number of the sub declaration (as extracted from the
compiled tree) is the sub's *last* line. Would it be possible to
have the first line instead?

Question 2:

#! /extra/perl/perl -w
sub f($){
    my $n = shift;
    return $n == 0 ? 1 : $n*f($n-1);
print f(5),"\n";

main::f() called too early to check prototype at /tmp/ line 4.

The warning goes away with sub f($); inserted before line 2, of
course. But one might assume that the prototype could be
available for checking after line 2. 

-Wolfgang Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About