File Coverage

blib/lib/Crypt/RSA/Debug.pm
Criterion Covered Total %
statement 10 26 38.4
branch 1 2 50.0
condition n/a
subroutine 4 5 80.0
pod 2 2 100.0
total 17 35 48.5


line stmt bran cond sub pod time code
1             package Crypt::RSA::Debug;
2 8     8   43 use strict;
  8         15  
  8         170  
3 8     8   35 use warnings;
  8         17  
  8         192  
4              
5             ## Crypt::RSA::Debug
6             ##
7             ## Copyright (c) 2001, Vipul Ved Prakash. All rights reserved.
8             ## This code is free software; you can redistribute it and/or modify
9             ## it under the same terms as Perl itself.
10              
11 8     8   54 use vars qw(@ISA @EXPORT_OK);
  8         17  
  8         2021  
12             require Exporter;
13             @ISA = qw(Exporter);
14              
15             @EXPORT_OK = qw(debug debuglevel);
16              
17             my $DEBUG = 0;
18              
19             sub debug{
20 7116 50   7116 1 81888 return unless $DEBUG;
21 0           my ($caller, undef) = caller;
22 0           my (undef,undef,$line,$sub) = caller(1); $sub =~ s/.*://;
  0            
23 0           $sub = sprintf "%12s()%4d", $sub, $line;
24 0           $sub .= " | " . (shift);
25 0           $sub =~ s/\x00/[0]/g;
26 0           $sub =~ s/\x01/[1]/g;
27 0           $sub =~ s/\x02/[2]/g;
28 0           $sub =~ s/\x04/[4]/g;
29 0           $sub =~ s/\x05/[5]/g;
30 0           $sub =~ s/\xff/[-]/g;
31 0           $sub =~ s/[\x00-\x1f]/\./g;
32 0           $sub =~ s/[\x7f-\xfe]/_/g;
33 0           print "$sub\n";
34             }
35              
36              
37             sub debuglevel {
38              
39 0     0 1   my ($level) = shift;
40 0           $DEBUG = $level;
41              
42             }
43              
44              
45             =head1 NAME
46              
47             Crypt::RSA::Debug - Debug routine for Crypt::RSA.
48              
49             =head1 SYNOPSIS
50              
51             use Crypt::RSA::Debug qw(debug);
52             debug ("oops!");
53              
54             =head1 DESCRIPTION
55              
56             The module provides support for the I method of debugging!
57              
58             =head1 FUNCTION
59              
60             =over 4
61              
62             =item B String
63              
64             Prints B on STDOUT, along with caller's function name and line number.
65              
66             =item B Integer
67              
68             Sets the class data I to specified value. The value
69             defaults to 0. Callers can use the debuglevel facility by
70             comparing $Crypt::RSA::DEBUG to the desired debug level before
71             generating a debug statement.
72              
73             =back
74              
75             =head1 AUTHOR
76              
77             Vipul Ved Prakash, Email@vipul.netE
78              
79             =cut
80              
81             1;
82