File Coverage

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


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