#
# print debudding message to STDERR
# prepended with caller identification
# when global variable $opt_V is set
#

use strict;

sub dpr {

    my(@message) = @_;
    my(@result) = ();

    @result = &print_message_with_caller_info(@message) if ($main::opt_b);
    return @result;
}

sub vpr {

    my(@message) = @_;
    my(@result) = ();

    @result = &print_message_with_caller_info(@message) if ($main::opt_V);
    return @result;
}


sub print_message_with_caller_info {

    my(@message) = @_;
    my($depth) = 1;
    my(@result) = ();
    my(@tmp) = ();
    my($package, $filename, $line, $subroutine);
    my($hasargs, $wantarr,  $evaltxt, $require);
    my($sub1, $sub2);

#    @result =
#    (($package, $filename, $line,   $subroutine, 
#     $hasargs, $wantarr,  $evaltxt, $require)   = caller($depth));

    @result = caller(2);
    $sub1   = (split /\:/, $result[3])[-1];
    @result = caller(3);
    $sub2   = (split /\:/, $result[3])[-1];

#    @tmp = split(/\:/, $subroutine);
#    $subroutine = $tmp[-1];

#    print STDERR "$subroutine -- ($$) @message" if ($main::opt_V);
    print STDERR "$sub1($sub2) - @message";

    return @result;
}



1;
