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

sub inconveniences

From:
Wolfgang Laun
Date:
December 21, 2001 07:24
Subject:
sub inconveniences
Message ID:
3C2353FE.5BF63991@alcatel.at
Maybe these two questions are related, maybe not.

Question 1:

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

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/try.pl 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. 

Regards,
-Wolfgang



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About