← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 11:58:52 2013
Reported on Tue Oct 15 12:01:07 2013

Filename/usr/share/perl5/Business/ISBN13.pm
StatementsExecuted 24 statements in 669µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11118µs77µsBusiness::ISBN13::::BEGIN@23Business::ISBN13::BEGIN@23
11116µs21µsBusiness::ISBN13::::BEGIN@4Business::ISBN13::BEGIN@4
11115µs230µsBusiness::ISBN13::::BEGIN@7Business::ISBN13::BEGIN@7
11113µs51µsBusiness::ISBN13::::BEGIN@8Business::ISBN13::BEGIN@8
11111µs76µsBusiness::ISBN13::::BEGIN@5Business::ISBN13::BEGIN@5
11110µs38µsBusiness::ISBN13::::BEGIN@10Business::ISBN13::BEGIN@10
11110µs45µsBusiness::ISBN13::::BEGIN@18Business::ISBN13::BEGIN@18
0000s0sBusiness::ISBN13::::_checksumBusiness::ISBN13::_checksum
0000s0sBusiness::ISBN13::::_hyphen_positionsBusiness::ISBN13::_hyphen_positions
0000s0sBusiness::ISBN13::::_max_lengthBusiness::ISBN13::_max_length
0000s0sBusiness::ISBN13::::_parse_prefixBusiness::ISBN13::_parse_prefix
0000s0sBusiness::ISBN13::::_set_prefixBusiness::ISBN13::_set_prefix
0000s0sBusiness::ISBN13::::_set_typeBusiness::ISBN13::_set_type
0000s0sBusiness::ISBN13::::as_isbn10Business::ISBN13::as_isbn10
0000s0sBusiness::ISBN13::::as_isbn13Business::ISBN13::as_isbn13
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# $Revision: 2.8 $
2# $Id: ISBN13.pm,v 2.8 2007/09/17 02:34:58 comdog Exp $
3package Business::ISBN13;
4331µs226µs
# spent 21µs (16+5) within Business::ISBN13::BEGIN@4 which was called: # once (16µs+5µs) by Business::ISBN::BEGIN@133 at line 4
use strict;
# spent 21µs making 1 call to Business::ISBN13::BEGIN@4 # spent 5µs making 1 call to strict::import
5352µs2140µs
# spent 76µs (11+64) within Business::ISBN13::BEGIN@5 which was called: # once (11µs+64µs) by Business::ISBN::BEGIN@133 at line 5
use base qw(Business::ISBN);
# spent 76µs making 1 call to Business::ISBN13::BEGIN@5 # spent 64µs making 1 call to base::import
6
7340µs2445µs
# spent 230µs (15+215) within Business::ISBN13::BEGIN@7 which was called: # once (15µs+215µs) by Business::ISBN::BEGIN@133 at line 7
use Business::ISBN qw(:all);
# spent 230µs making 1 call to Business::ISBN13::BEGIN@7 # spent 215µs making 1 call to Exporter::import
8344µs289µs
# spent 51µs (13+38) within Business::ISBN13::BEGIN@8 which was called: # once (13µs+38µs) by Business::ISBN::BEGIN@133 at line 8
use Data::Dumper;
# spent 51µs making 1 call to Business::ISBN13::BEGIN@8 # spent 38µs making 1 call to Exporter::import
9
10128µs
# spent 38µs (10+28) within Business::ISBN13::BEGIN@10 which was called: # once (10µs+28µs) by Business::ISBN::BEGIN@133 at line 17
use subs qw(
# spent 28µs making 1 call to subs::import
11 _checksum
12 INVALID_COUNTRY_CODE
13 INVALID_PUBLISHER_CODE
14 BAD_CHECKSUM
15 GOOD_ISBN
16 BAD_ISBN
17331µs138µs );
# spent 38µs making 1 call to Business::ISBN13::BEGIN@10
18136µs
# spent 45µs (10+36) within Business::ISBN13::BEGIN@18 which was called: # once (10µs+36µs) by Business::ISBN::BEGIN@133 at line 21
use vars qw(
# spent 36µs making 1 call to vars::import
19 $VERSION
20 $debug
21350µs145µs );
# spent 45µs making 1 call to Business::ISBN13::BEGIN@18
22
233416µs2136µs
# spent 77µs (18+59) within Business::ISBN13::BEGIN@23 which was called: # once (18µs+59µs) by Business::ISBN::BEGIN@133 at line 23
use Carp qw(carp croak cluck);
# spent 77µs making 1 call to Business::ISBN13::BEGIN@23 # spent 59µs making 1 call to Exporter::import
24
251800nsmy $debug = 0;
26
271600ns$VERSION = '2.05';
28
29sub _max_length { 13 }
30
31sub _set_type { $_[0]->{type} = 'ISBN13' }
32
33sub _parse_prefix
34 {
35 my $isbn = $_[0]->isbn; # stupid workaround for 'Can't modify non-lvalue subroutine call'
36 ( $isbn =~ /\A(97[89])(.{10})\z/g )[0];
37 }
38
39sub _set_prefix
40 {
41 croak "Cannot set prefix [$_[1]] on an ISBN-13"
42 unless $_[1] =~ m/\A97[89]\z/;
43
44 $_[0]->{prefix} = $_[1];
45 }
46
47sub _hyphen_positions
48 {
49 [
50 $_[0]->_prefix_length,
51 $_[0]->_prefix_length + $_[0]->_group_code_length,
52 $_[0]->_prefix_length + $_[0]->_group_code_length + $_[0]->_publisher_code_length,
53 $_[0]->_checksum_pos,
54 ]
55 }
56
57# sub group { 'Bookland' }
58
59sub as_isbn10
60 {
61 my $self = shift;
62
63 return unless $self->prefix eq '978';
64
65 my $isbn10 = Business::ISBN->new(
66 substr( $self->isbn, 3 )
67 );
68 $isbn10->fix_checksum;
69
70 return $isbn10;
71 }
72
73sub as_isbn13
74 {
75 my $self = shift;
76
77 my $isbn13 = Business::ISBN->new( $self->as_string );
78 $isbn13->fix_checksum;
79
80 return $isbn13;
81 }
82
83#internal function. you don't get to use this one.
84sub _checksum
85 {
86 my $data = $_[0]->isbn;
87
88 return unless defined $data;
89
90 my @digits = split //, $data;
91 my $sum = 0;
92
93 foreach my $index ( 0, 2, 4, 6, 8, 10 )
94 {
95 $sum += substr($data, $index, 1);
96 $sum += 3 * substr($data, $index + 1, 1);
97 }
98
99 #take the next higher multiple of 10 and subtract the sum.
100 #if $sum is 37, the next highest multiple of ten is 40. the
101 #check digit would be 40 - 37 => 3.
102 my $checksum = ( 10 * ( int( $sum / 10 ) + 1 ) - $sum ) % 10;
103
104 return $checksum;
105 }
106
107
10814µs1;
109
110__END__