Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

caller

use strict;
use warnings;

fib(4);

sub fib {
    my $n = shift;
    my ($package, $filename, $line) = caller(0);
    print "$package  $filename  $line\n";
    if ($n == 1 or $n == 2) {
        return 1;
    }
    return fib($n-1) + fib($n-2);
}
use strict;
use warnings;

f();

sub f {
    g();
}

sub g {
    h();
}

sub h {
    for my $i (0..2) {
        my ($package, $filename, $line, $subroutine, $hasargs, $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash) = caller($i);
        print "$i: $package  $filename  $line $subroutine\n";
    }
}