blib/lib/Religion/Islam/Quran.pm

filter: Statementstmt 16.7% 28 / 167 Branchbran 0.0% 0 / 66 Conditioncond 0.0% 0 / 55 MC/DCmcdc 0.0% 0 / 36 Subroutinesub 18.5% 5 / 27 Podpod 0.0% 0 / 21 totaltotal 8.8% 33 / 372 CC 58 SCAR 37.4
CC
58
Cov
10%
Ayats
110.0
AyatsHash
90.0
_initialize
72.0
CRAP 42.2
↑ Summary
1 #=Copyright Infomation
2 #==========================================================
3 #Module Name : Religion::Islam::Quran
4 #Program Author : Dr. Ahmed Amin Elsheshtawy, Ph.D. Physics, E.E.
5 #Home Page : http://www.islamware.com, http://www.mewsoft.com
6 #Contact Email : support@islamware.com, support@mewsoft.com
7 #Copyrights © 2006-2013 IslamWare. All rights reserved.
8 #==========================================================
9 package Religion::Islam::Quran;
10  
11 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 our @ISA = qw(Exporter);
18 1 our @EXPORT = qw();
19  
20 1 our $VERSION = '2.01';
21 1 our %quran;
22 1 our %OrderOfRevelation;
23 1 our @QuranLanguages;
24 1 our %surah_name;
25 #==========================================================
26 1 our %SajdahCompulsaryAyats = (
27 32 => 15, #Surah 32 as-Sajdah / Ayat 15
28 41 => 38, #Surah 41 al-Fusilat / Ayat 38
29 53 => 62, #Surah 53 an-Najm / Ayat 62
30 96 => 19 #Surah 96 al-Alaq / Ayat 19
31 );
32  
33 1 our %SajdahRecommendedAyats = (
34 7 => 206, #Sura 7 - Al A'raf (The Elevated Places) - Ayat 206
35 13 => 15, #Sura 13 - Ar Ra'ad (The Thunder) - Ayat 15
36 16 => 50, #Sura 16 - An Nahl (The Bee) - Ayat 50
37 17 => 109, #Sura 17 - Bani Israil (The Children of Israil) - Ayat 109
38 19 => 58, #Sura 19 - Marium (Mary) - Ayat 58
39 22 => 18, #Sura 22 - Al Haj (The Pilgrimage) - Ayat 18
40 25 => 60, #Sura 25 - Al Furqan (The Criterion) - Ayat 60
41 27 => 26, #Sura 27 - An Naml (The Ant) - Ayat 26
42 38 => 24, #Sura 38 - Saad (Saad) - Ayat 24
43 84 => 21 #Sura 84 - Al Inshiqaq (The Bursting Asunder) - Ayat 21
44 );
45 #----------------------------------------------------------------
46 #Surah Number Order of Revelation
47 1 %OrderOfRevelation = (
48 1=>5,
49 2=>87,
50 3=>89,
51 4=>92,
52 5=>112,
53 6=>55,
54 7=>39,
55 8=>88,
56 9=>113,
57 10=>51,
58 11=>52,
59 12=>53,
60 13=>96,
61 14=>72,
62 15=>54,
63 16=>70,
64 17=>50,
65 18=>69,
66 19=>44,
67 20=>45,
68 21=>73,
69 22=>103,
70 23=>74,
71 24=>102,
72 25=>42,
73 26=>47,
74 27=>48,
75 28=>49,
76 29=>85,
77 30=>84,
78 31=>57,
79 32=>75,
80 33=>90,
81 34=>58,
82 35=>43,
83 36=>41,
84 37=>56,
85 38=>38,
86 39=>59,
87 40=>60,
88 41=>61,
89 42=>62,
90 43=>63,
91 44=>64,
92 45=>65,
93 46=>66,
94 47=>95,
95 48=>111,
96 49=>106,
97 50=>34,
98 51=>67,
99 52=>76,
100 53=>23,
101 54=>37,
102 55=>97,
103 56=>46,
104 57=>94,
105 58=>105,
106 59=>101,
107 60=>13,
108 61=>109,
109 62=>110,
110 63=>104,
111 64=>108,
112 65=>99,
113 66=>107,
114 67=>77,
115 68=>2,
116 69=>78,
117 70=>79,
118 71=>71,
119 72=>40,
120 73=>3,
121 74=>4,
122 75=>31,
123 76=>98,
124 77=>33,
125 78=>80,
126 79=>81,
127 80=>24,
128 81=>7,
129 82=>82,
130 83=>86,
131 84=>83,
132 85=>27,
133 86=>36,
134 87=>8,
135 88=>68,
136 89=>10,
137 90=>35,
138 91=>26,
139 92=>9,
140 93=>11,
141 94=>12,
142 95=>28,
143 96=>1,
144 97=>25,
145 98=>100,
146 99=>93,
147 100=>14,
148 101=>30,
149 102=>16,
150 103=>13,
151 104=>32,
152 105=>19,
153 106=>29,
154 107=>17,
155 108=>15,
156 109=>18,
157 110=>114,
158 111=>6,
159 112=>22,
160 113=>20,
161 114=>21
162 );
163  
164 1 %surah_name = (
165 'Arabic' => [
166 "الفاتحة",
167 "البقرة",
168 "ال عمران",
169 "النساء",
170 "المائدة",
171 "الانعام",
172 "الاعراف",
173 "الانفال",
174 "التوبة",
175 "يونس",
176 "هود",
177 "يوسف",
178 "الرعد",
179 "ابراهيم",
180 "الحجر",
181 "النحل",
182 "الاسراء",
183 "الكهف",
184 "مريم",
185 "طه",
186 "الانبياء",
187 "الحج",
188 "المؤمنون",
189 "النور",
190 "الفرقان",
191 "الشعراء",
192 "النمل",
193 "القصص",
194 "العنكبوت",
195 "الروم",
196 "لقمان",
197 "السجدة",
198 "الاحزاب",
199 "سبأ",
200 "فاطر",
201 "يس",
202 "الصافات",
203 "ص",
204 "الزمر",
205 "غافر",
206 "فصلت",
207 "الشورى",
208 "الزخرف",
209 "الدخان",
210 "الجاثية",
211 "الاحقاف",
212 "محمد",
213 "الفتح",
214 "الحجرات",
215 "ق",
216 "الذاريات",
217 "الطور",
218 "النجم",
219 "القمر",
220 "الرحمن",
221 "الواقعة",
222 "الحديد",
223 "المجادلة",
224 "الحشر",
225 "الممتحنة",
226 "الصف",
227 "الجمعة",
228 "المنافقون",
229 "التغابن",
230 "الطلاق",
231 "التحريم",
232 "الملك",
233 "القلم",
234 "الحاقة",
235 "المعارج",
236 "نوح",
237 "الجن",
238 "المزمل",
239 "المدثر",
240 "القيامة",
241 "الانسان",
242 "المرسلات",
243 "النبا",
244 "النازعات",
245 "عبس",
246 "التكوير",
247 "الانفطار",
248 "المطففين",
249 "الانشقاق",
250 "البروج",
251 "الطارق",
252 "الاعلى",
253 "الغاشية",
254 "الفجر",
255 "البلد",
256 "الشمس",
257 "الليل",
258 "الضحى",
259 "الشرح",
260 "التين",
261 "العلق",
262 "القدر",
263 "البينة",
264 "الزلزلة",
265 "العاديات",
266 "القارعة",
267 "التكاثر",
268 "العصر",
269 "الهمزة",
270 "الفيل",
271 "قريش",
272 "الماعون",
273 "الكوثر",
274 "الكافرون",
275 "النصر",
276 "المسد",
277 "الاخلاص",
278 "الفلق",
279 "الناس"
280 ],
281  
282 'English' => [
283 "Al-Fatiha",
284 "Al-Baqarah",
285 "Al-'Imran",
286 "An-Nisa",
287 "Al-Ma'idah",
288 "Al-An'am",
289 "Al-A'raf",
290 "Al-Anfal",
291 "At-Taubah",
292 "Yunus",
293 "Hud",
294 "Yusuf",
295 "Ar-Ra'd",
296 "Ibrahim",
297 "Al-Hijr",
298 "An-Nahl",
299 "Al-Isra'",
300 "Al-Kahf",
301 "Maryam",
302 "Ta-Ha",
303 "Al-Anbiya",
304 "Al-Hajj",
305 "Al-Mu'minun",
306 "An-Nur",
307 "Al-Furqan",
308 "Ash-Shu'ara",
309 "An-Naml",
310 "Al-Qasas",
311 "Al-Ankabut",
312 "Ar-Rum",
313 "Luqman",
314 "As-Sajdah",
315 "Al-Ahzab",
316 "Saba",
317 "Fatir",
318 "Ya-Sin",
319 "As-Saffaat",
320 "Saad",
321 "Az-Zumar",
322 "Ghafir",
323 "Fussilat",
324 "Ash-Shura",
325 "Az-Zukhruf",
326 "Ad-Dukhan",
327 "Al-Jathiyah",
328 "Al-Ahqaf",
329 "Muhammad",
330 "Al-Fath",
331 "Al-Hujuraat",
332 "Qaf",
333 "Adh-Dhariyat",
334 "At-Tur",
335 "An-Najm",
336 "Al-Qamar",
337 "Ar-Rahman",
338 "Al-Waqi'ah",
339 "Al-Hadid",
340 "Al-Mujadilah",
341 "Al-Hashr",
342 "Al-Mumtahana",
343 "As-Saff",
344 "Al-Jumu'ah",
345 "Al-Munafiqun",
346 "At-Taghabun",
347 "At-Talaaq",
348 "At-Tahrim",
349 "Al-Mulk",
350 "Al-Qalam",
351 "Al-Haqqah",
352 "Al-Ma'arij",
353 "Nuh",
354 "Al-Jinn",
355 "Al-Muzzammil",
356 "Al-Muddathir",
357 "Al-Qiyamah",
358 "Al-Insan",
359 "Al-Mursalaat",
360 "An-Naba",
361 "An-Nazi'aat",
362 "'Abasa",
363 "At-Takwir",
364 "Al-Infitaar",
365 "Al-Mutaffifi",
366 "Al-Inshiqaq",
367 "Al-Buruj",
368 "At-Tariq",
369 "Al-A'la",
370 "Al-Ghaashiya",
371 "Al-Fajr",
372 "Al-Balad",
373 "Ash-Shams",
374 "Al-Lail",
375 "Ad-Duha",
376 "Ash-Sharh",
377 "At-Tin",
378 "Al-'Alaq",
379 "Al-Qadr",
380 "Al-Baiyyinah",
381 "Az-Zalzalah",
382 "Al-'Aadiyaat",
383 "Al-Qari'ah",
384 "At-Takaathur",
385 "Al-'Asr",
386 "Al-Humazah",
387 "Al-Fil",
388 "Al-Quraish",
389 "Al-Maa'un",
390 "Al-Kauthar",
391 "Al-Kaafirun",
392 "An-Nasr",
393 "Al-Masad",
394 "Al-Ikhlaas",
395 "Al-Falaq",
396 "An-Naas"
397 ]
398 );
399  
400 1 our @surah_ayah_count = (7,286,200,176,120,165,206,75,129,109,123,111,43,52,99,128,111,110,98,
401 135,112,78,118,64,77,227,93,88,69,60,34,30,73,54,45,83,182,88,75,85,54,
402 53,89,59,37,35,38,29,18,45,60,49,62,55,78,96,29,22,24,13,14,11,11,18,12,
403 12,30,52,52,44,28,28,20,56,40,31,50,40,46,42,29,19,36,25,22,17,19,26,30,
404 20,15,21,11,8,8,19,5,8,8,11,11,8,3,9,5,4,7,3,6,3,5,4,5,6);
405 #==========================================================
406 0 ▶sub new {
Subroutine new: not called CC=4 SCAR=30.0
Pod undocumented
407 0 my ($class, %args) = @_;
408
409 0 my $self = bless {}, $class;
410 0 ▶ $self->{Language} = $args{Language}? $args{Language}: 'Arabic';
Branch: 1 branch
BranchTrueFalseTotal
$args{'Language'} ? : 0 0 0
411 0 ▶ $self->{DatabasePath} = $args{DatabasePath}? $args{DatabasePath}: $INC{"Religion/Islam/Quran.pm"};
Branch: 1 branch
BranchTrueFalseTotal
$args{'DatabasePath'} ? : 0 0 0
412 0 $self->{DatabasePath} =~ s/\.pm$//;
413 0 ▶ croak("Can't find base directory of Religion::Islam::Quran!") unless (-d $self->{DatabasePath});
Branch: 1 branch
BranchTrueFalseTotal
unless -d $self->{"DatabasePath"} 0 0 0
414 0 $self->{DatabaseFile} = "$self->{DatabasePath}/"."Quran". $self->{Language} .".txt";
415 0 $self->_initialize;
416 0 return $self;
417 }
418 #==========================================================
419 0 ▶sub _initialize{
Subroutine _initialize: not called CC=8 SCAR=42.8
420 0 my ($self) = @_;
421 0 my ($line, $surah, $ayah, $description);
422
423 0 ▶ unless (-f $self->{DatabaseFile}) {croak ("Unable to find Quran Database file $self->{DatabaseFile}: $!.");}
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $self->{"DatabaseFile"}) 0 0 0
424 0 ▶ open (IN, "<:encoding(UTF-8)", "$self->{DatabaseFile}") || croak("Unable to open Quran Database file $self->{DatabaseFile}: $!.");
Branch: 1 branch
BranchTrueFalseTotal
open IN, "<:encoding(UTF-8)", qq[$self->{"DatabaseFile"}] or croak(qq[Unable to open Quran Database file $self->{"DatabaseFile"}: $!.]) 0 0 0
425  
426 0 %quran = ();
427  
428 0 ▶ while ($line = <IN>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline IN)) 0 0 0
429 0 chomp ($line);
430 0 ($surah, $ayah, $description) = split(/\|/, $line);
431 0 $quran{"$surah\_$ayah"} = $description;
432 }
433 0 close IN;
434 #----------------------------------------------------------------
435 0 @QuranLanguages = ();
436 0 ▶ opendir (DBdir, $self->{DatabasePath}) || croak("Unable to open Quran Database directory $self->{DatabasePath}: $!.");
Branch: 1 branch
BranchTrueFalseTotal
opendir DBdir, $self->{"DatabasePath"} or croak(qq[Unable to open Quran Database directory $self->{"DatabasePath"}: $!.]) 0 0 0
437 0 ▶ while (my $file = readdir(DBdir)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $file = readdir DBdir)) 0 0 0
438 0 ▶ if ($file eq "." || $file eq "..") {next;}
Branch: 1 branch
BranchTrueFalseTotal
if ($file eq "." or $file eq "..") 0 0 0
Condition0%0/3
$file eq "." or $file eq ".."
l!l&&r!l&&!r
000
MC/DC0%0/2
$file eq "." or $file eq ".."
$file eq "." $file eq ".."
Truth table0%0/3
A or B
A= $file eq "."B= $file eq ".."
ABresult
1X1
011
000
439 0 $file =~ s/\.txt$//;
440 0 $file =~ s/^Quran//;
441 0 push @QuranLanguages, $file;
442 }
443 }
444 #==========================================================
445 0 ▶sub GetLanguages{
Subroutine GetLanguages: not called CC=1 SCAR=6.9
Pod undocumented
446 0 my ($self) = @_;
447 0 return @QuranLanguages;
448 }
449 #==========================================================
450 0 ▶sub SurahCount{
Subroutine SurahCount: not called CC=1 SCAR=6.9
Pod undocumented
451 0 my ($self) = @_;
452 0 return 114;
453 }
454 #==========================================================
455 0 ▶sub AyahCount{
Subroutine AyahCount: not called CC=1 SCAR=6.9
Pod undocumented
456 0 my ($self) = @_;
457 0 return 6236;
458 }
459 #==========================================================
460 0 ▶sub SurahAyahCount{
Subroutine SurahAyahCount: not called CC=3 SCAR=24.8
Pod undocumented
461 0 my ($self, $surah) = @_;
462
463 0 ▶ if ($surah<1 || $surah>114) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($surah < 1 or $surah > 114) 0 0 0
Condition0%0/3
$surah < 1 or $surah > 114
l!l&&r!l&&!r
000
MC/DC0%0/2
$surah < 1 or $surah > 114
$surah < 1 $surah > 114
Truth table0%0/3
A or B
A= $surah < 1B= $surah > 114
ABresult
1X1
011
000
464 0 return $surah_ayah_count[$surah-1];
465 }
466 #==========================================================
467 0 ▶sub SurahName{
Subroutine SurahName: not called CC=6 SCAR=37.4
Pod undocumented
468 0 my ($self, $surah, $lang) = @_;
469
470 0 ▶ if ($surah<1 || $surah>114) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($surah < 1 or $surah > 114) 0 0 0
Condition0%0/3
$surah < 1 or $surah > 114
l!l&&r!l&&!r
000
MC/DC0%0/2
$surah < 1 or $surah > 114
$surah < 1 $surah > 114
Truth table0%0/3
A or B
A= $surah < 1B= $surah > 114
ABresult
1X1
011
000
471 0 ▶ $lang ||= $self->{Language} ||= "English";
Condition0%0/5
$lang ||= ($self->{"Language"} ||= "English")
l!l&&r!l&&!r
000
$self->{"Language"} ||= "English"
l!l
00
MC/DC0%0/2
$lang ||= ($self->{"Language"} ||= "English")
$lang ($self->{"Language"} ||= "English")
MC/DC0%0/1
$self->{"Language"} ||= "English"
$self->{"Language"}
Truth table0%0/3
A ||= B
A= $langB= ($self->{"Language"} ||= "English")
ABresult
1X1
011
000
Truth table0%0/2
A
A= $self->{"Language"}
Aresult
11
00
472 0 ▶ if (!exists $surah_name{$lang}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $Religion::Islam::Quran::surah_name{$lang}) 0 0 0
473 0 $lang = "English";
474 }
475 0 return $surah_name{$lang}->[$surah-1];
476 }
477 #==========================================================
478 0 ▶sub SurahsNames{
Subroutine SurahsNames: not called CC=4 SCAR=30.0
Pod undocumented
479 0 my ($self, $lang) = @_;
480 0 ▶ $lang ||= $self->{Language} ||= "English";
Condition0%0/5
$lang ||= ($self->{"Language"} ||= "English")
l!l&&r!l&&!r
000
$self->{"Language"} ||= "English"
l!l
00
MC/DC0%0/2
$lang ||= ($self->{"Language"} ||= "English")
$lang ($self->{"Language"} ||= "English")
MC/DC0%0/1
$self->{"Language"} ||= "English"
$self->{"Language"}
Truth table0%0/3
A ||= B
A= $langB= ($self->{"Language"} ||= "English")
ABresult
1X1
011
000
Truth table0%0/2
A
A= $self->{"Language"}
Aresult
11
00
481 0 ▶ if (!exists $surah_name{$lang}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $Religion::Islam::Quran::surah_name{$lang}) 0 0 0
482 0 $lang = "English";
483 }
484 0 return @{$surah_name{$lang}};
485 }
486 #==========================================================
487 0 ▶sub Ayah{
Subroutine Ayah: not called CC=2 SCAR=17.9
Pod undocumented
488 0 my ($self, $surah, $ayah) = @_;
489 0 ▶ $quran{"$surah\_$ayah"} || return undef;
Branch: 1 branch
BranchTrueFalseTotal
$Religion::Islam::Quran::quran{"${surah}_$ayah"} or return undef 0 0 0
490 0 return $quran{"$surah\_$ayah"};
491 }
492 #==========================================================
493 0 ▶sub Ayats{
Subroutine Ayats: not called CC=10 SCAR=47.0
Pod undocumented
494 0 my ($self, $surah, $fromayah, $toayah) = @_;
495 0 my (@ayats, $ayats, $ayah, $counter);
496
497 0 ▶ wantarray || return undef;
Branch: 1 branch
BranchTrueFalseTotal
wantarray or return undef 0 0 0
498  
499 0 ▶ if ($surah<1 || $surah>114) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($surah < 1 or $surah > 114) 0 0 0
Condition0%0/3
$surah < 1 or $surah > 114
l!l&&r!l&&!r
000
MC/DC0%0/2
$surah < 1 or $surah > 114
$surah < 1 $surah > 114
Truth table0%0/3
A or B
A= $surah < 1B= $surah > 114
ABresult
1X1
011
000
500 0 $ayats = $surah_ayah_count[$surah-1];
501
502 0 ▶ if ($fromayah<1 || $fromayah>$ayats) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($fromayah < 1 or $fromayah > $ayats) 0 0 0
Condition0%0/3
$fromayah < 1 or $fromayah > $ayats
l!l&&r!l&&!r
000
MC/DC0%0/2
$fromayah < 1 or $fromayah > $ayats
$fromayah < 1 $fromayah > $ayats
Truth table0%0/3
A or B
A= $fromayah < 1B= $fromayah > $ayats
ABresult
1X1
011
000
503 0 ▶ if ($toayah<1 || $toayah>$ayats) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($toayah < 1 or $toayah > $ayats) 0 0 0
Condition0%0/3
$toayah < 1 or $toayah > $ayats
l!l&&r!l&&!r
000
MC/DC0%0/2
$toayah < 1 or $toayah > $ayats
$toayah < 1 $toayah > $ayats
Truth table0%0/3
A or B
A= $toayah < 1B= $toayah > $ayats
ABresult
1X1
011
000
504  
505 0 ▶ if ($fromayah > $toayah) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fromayah > $toayah) 0 0 0
506 0 ($fromayah, $toayah) = ($toayah, $fromayah);
507 }
508
509 0 $counter = 0;
510 0 for $ayah($fromayah..$toayah) {
511 0 $ayats[$counter++] = $quran{"$surah\_$ayah"};
512 }
513 0 return @ayats;
514 }
515 #==========================================================
516 0 ▶sub AyatsHash{
Subroutine AyatsHash: not called CC=9 SCAR=45.0
Pod undocumented
517 0 my ($self, $surah, $fromayah, $toayah) = @_;
518 0 my (%ayats, $ayats, $ayah, $counter);
519
520 0 ▶ if ($surah<1 || $surah>114) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($surah < 1 or $surah > 114) 0 0 0
Condition0%0/3
$surah < 1 or $surah > 114
l!l&&r!l&&!r
000
MC/DC0%0/2
$surah < 1 or $surah > 114
$surah < 1 $surah > 114
Truth table0%0/3
A or B
A= $surah < 1B= $surah > 114
ABresult
1X1
011
000
521 0 $ayats = $surah_ayah_count[$surah-1];
522
523 0 ▶ if ($fromayah<1 || $fromayah>$ayats) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($fromayah < 1 or $fromayah > $ayats) 0 0 0
Condition0%0/3
$fromayah < 1 or $fromayah > $ayats
l!l&&r!l&&!r
000
MC/DC0%0/2
$fromayah < 1 or $fromayah > $ayats
$fromayah < 1 $fromayah > $ayats
Truth table0%0/3
A or B
A= $fromayah < 1B= $fromayah > $ayats
ABresult
1X1
011
000
524 0 ▶ if ($toayah<1 || $toayah>$ayats) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($toayah < 1 or $toayah > $ayats) 0 0 0
Condition0%0/3
$toayah < 1 or $toayah > $ayats
l!l&&r!l&&!r
000
MC/DC0%0/2
$toayah < 1 or $toayah > $ayats
$toayah < 1 $toayah > $ayats
Truth table0%0/3
A or B
A= $toayah < 1B= $toayah > $ayats
ABresult
1X1
011
000
525  
526 0 ▶ if ($fromayah > $toayah) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fromayah > $toayah) 0 0 0
527 0 ($fromayah, $toayah) = ($toayah, $fromayah);
528 }
529
530 0 $counter = 0;
531 0 for $ayah($fromayah..$toayah) {
532 0 $ayats{$ayah} = $quran{"$surah\_$ayah"};
533 }
534 0 return %ayats;
535 }
536 #==========================================================
537 0 ▶sub SearchSurah{
Subroutine SearchSurah: not called CC=5 SCAR=34.0
Pod undocumented
538 0 my ($self, $surah, $findwhat) = @_;
539 0 my (@ayats, $ayats, $ayah, $counter);
540
541 0 ▶ if ($surah<1 || $surah>114) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($surah < 1 or $surah > 114) 0 0 0
Condition0%0/3
$surah < 1 or $surah > 114
l!l&&r!l&&!r
000
MC/DC0%0/2
$surah < 1 or $surah > 114
$surah < 1 $surah > 114
Truth table0%0/3
A or B
A= $surah < 1B= $surah > 114
ABresult
1X1
011
000
542 0 $ayats = $surah_ayah_count[$surah-1];
543
544 0 $counter = 0;
545 0 for $ayah(1..$ayats) {
546 0 ▶ if ($quran{"$surah\_$ayah"} =~ m/$findwhat/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Religion::Islam::Quran::quran{"${surah}_$ayah"} =~ /$findwhat/i) 0 0 0
547 0 $ayats[$counter++] = $ayah;
548 }
549 }
550 0 return @ayats;
551 }
552 #==========================================================
553 0 ▶sub Surah{
Subroutine Surah: not called CC=4 SCAR=30.0
Pod undocumented
554 0 my ($self, $surah) = @_;
555 0 my (@surah, $ayats, $ayah);
556  
557 0 ▶ if ($surah<1 || $surah>114) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($surah < 1 or $surah > 114) 0 0 0
Condition0%0/3
$surah < 1 or $surah > 114
l!l&&r!l&&!r
000
MC/DC0%0/2
$surah < 1 or $surah > 114
$surah < 1 $surah > 114
Truth table0%0/3
A or B
A= $surah < 1B= $surah > 114
ABresult
1X1
011
000
558 0 $ayats = $surah_ayah_count[$surah-1];
559 0 for $ayah(1..$ayats) {
560 0 $surah[$ayah] = $quran{"$surah\_$ayah"};
561 }
562 0 return @surah;
563 }
564 #==========================================================
565 0 ▶sub SurahsAyats{
Subroutine SurahsAyats: not called CC=1 SCAR=6.9
Pod undocumented
566 0 my ($self) = @_;
567 0 return @surah_ayah_count;
568 }
569 #==========================================================
570 #The Wajib Sajdah of the Qur'an
571 #In four Surahs of the Qur'an there are ayats of sajdah that if a person reads one of these ayats, or if he hears someone else recite one of these ayats, once the ayat is finished, one must immediately go into sajdah.
572 #The Surahs that contain an ayat of wajib sajdah are:
573 #Surah 32 as-Sajdah / Ayat 15
574 #Surah 41 al-Fusilat / Ayat 38
575 #Surah 53 an-Najm / Ayat 62
576 #Surah 96 al-Alaq / Ayat 19
577 #If one forgets to perform the sajdah, whenever one remembers he must perform the sajdah.
578 #If the ayat of sajdah is heard over a tape recorder or things like this (CD, computer, etc...), the sajdah is not wajib.
579 #If one hears the ayat of sajdah over a speaker, it is wajib to perform the sajdah.
580 #If one hears the ayat of sajdah over the radio, in the event that the radio program is live (meaning the reciter is in the radio reciting the ayat), once the ayat is completed and the radio broadcasts it, the sajdah is wajib; but if the radio plays the ayat of sajdah from a tape of the Qur'an, the sajdah is not wajib.
581 #It is not wajib to recite a dhikr while in this sajdah, but it is mustahab.
582  
583 #Following Ayaat require compulsary (wajib) sajda (indicated by *):
584 #1) Sura 32 - As Sajdah (The Adoration) - Ayat 15
585 #2) Sura 41 - Ha Mim (Ha Mim) - Ayat 38
586 #3) Sura 53 - An Najm (The Star) - Ayat 62
587 #4) Sura 96 - Al Alaq (The Clot) - Ayat 19
588 #
589 #Following Ayaat require recommended (mustahab) sajda (indicated by *):
590 #5) Sura 7 - Al A'raf (The Elevated Places) - Ayat 206
591 #6) Sura 13 - Ar Ra'ad (The Thunder) - Ayat 15
592 #7) Sura 16 - An Nahl (The Bee) - Ayat 50
593 #8) Sura 17 - Bani Israil (The Children of Israil) - Ayat 109
594 #9) Sura 19 - Marium (Mary) - Ayat 58
595 #10) Sura 22 - Al Haj (The Pilgrimage) - Ayat 18
596 #11) Sura 25 - Al Furqan (The Criterion) - Ayat 60
597 #12) Sura 27 - An Naml (The Ant) - Ayat 26
598 #13) Sura 38 - Saad (Saad) - Ayat 24
599 #14) Sura 84 - Al Inshiqaq (The Bursting Asunder) - Ayat 21
600 #==========================================================
601 0 ▶sub SajdahCompulsaryAyats{
Subroutine SajdahCompulsaryAyats: not called CC=1 SCAR=6.9
Pod undocumented
602 0 my ($self) = @_;
603 0 return %SajdahCompulsaryAyats;
604 }
605 #==========================================================
606 0 ▶sub IsSajdahCompulsaryAyah{
Subroutine IsSajdahCompulsaryAyah: not called CC=4 SCAR=30.0
Pod undocumented
607 0 my ($self, $surah, $ayah) = @_;
608
609 0 ▶ if ($surah<1 || $surah>114) {return 0;}
Branch: 1 branch
BranchTrueFalseTotal
if ($surah < 1 or $surah > 114) 0 0 0
Condition0%0/3
$surah < 1 or $surah > 114
l!l&&r!l&&!r
000
MC/DC0%0/2
$surah < 1 or $surah > 114
$surah < 1 $surah > 114
Truth table0%0/3
A or B
A= $surah < 1B= $surah > 114
ABresult
1X1
011
000
610 0 ▶ if ($SajdahCompulsaryAyats{$surah} eq $ayah ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Religion::Islam::Quran::SajdahCompulsaryAyats{$surah} eq $ayah) { } 0 0 0
611 0 return 1;
612 }
613 else {
614 0 return 0;
615 }
616 }
617 #==========================================================
618 0 ▶sub SajdahRecommendedAyats{
Subroutine SajdahRecommendedAyats: not called CC=1 SCAR=6.9
Pod undocumented
619 0 my ($self) = @_;
620 0 return %SajdahRecommendedAyats;
621 }
622 #==========================================================
623 0 ▶sub IsSajdahRecommendedAyah{
Subroutine IsSajdahRecommendedAyah: not called CC=4 SCAR=30.0
Pod undocumented
624 0 my ($self, $surah, $ayah) = @_;
625
626 0 ▶ if ($surah<1 || $surah>114) {return 0;}
Branch: 1 branch
BranchTrueFalseTotal
if ($surah < 1 or $surah > 114) 0 0 0
Condition0%0/3
$surah < 1 or $surah > 114
l!l&&r!l&&!r
000
MC/DC0%0/2
$surah < 1 or $surah > 114
$surah < 1 $surah > 114
Truth table0%0/3
A or B
A= $surah < 1B= $surah > 114
ABresult
1X1
011
000
627 0 ▶ if ($SajdahRecommendedAyats{$surah} eq $ayah ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Religion::Islam::Quran::SajdahRecommendedAyats{$surah} eq $ayah) { } 0 0 0
628 0 return 1;
629 }
630 else {
631 0 return 0;
632 }
633 }
634 #==========================================================
635 0 ▶sub SurahOrderOfRevelation{
Subroutine SurahOrderOfRevelation: not called CC=3 SCAR=24.8
Pod undocumented
636 0 my ($self, $surah) = @_;
637 0 ▶ if ($surah<1 || $surah>114) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($surah < 1 or $surah > 114) 0 0 0
Condition0%0/3
$surah < 1 or $surah > 114
l!l&&r!l&&!r
000
MC/DC0%0/2
$surah < 1 or $surah > 114
$surah < 1 $surah > 114
Truth table0%0/3
A or B
A= $surah < 1B= $surah > 114
ABresult
1X1
011
000
638 0 return $OrderOfRevelation{$surah};
639 }
640 #==========================================================
641 0 ▶sub OrderOfRevelation{
Subroutine OrderOfRevelation: not called CC=1 SCAR=6.9
Pod undocumented
642 0 my ($self) = @_;
643 0 return %OrderOfRevelation;
644 }
645 #==========================================================
646 #Where each surah revealed, Mekkah or Medianh
647 #Medinah surahs: 2, 3, 4, 5, 8, 9, 13, 22, 24, 33, 47, 48, 49, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 76, 98, 99, 110
648 #Return 1 for Medinah and 0 for Mekkah
649 0 ▶sub SurahRevelation{
Subroutine SurahRevelation: not called CC=5 SCAR=34.0
Pod undocumented
650 0 my ($self, $surah) = @_;
651 0 my (@medinah) = (2, 3, 4, 5, 8, 9, 13, 22, 24, 33, 47, 48, 49, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 76, 98, 99, 110); # Medinah surahs
652  
653 0 ▶ if ($surah<1 || $surah>114) {return undef;}
Branch: 1 branch
BranchTrueFalseTotal
if ($surah < 1 or $surah > 114) 0 0 0
Condition0%0/3
$surah < 1 or $surah > 114
l!l&&r!l&&!r
000
MC/DC0%0/2
$surah < 1 or $surah > 114
$surah < 1 $surah > 114
Truth table0%0/3
A or B
A= $surah < 1B= $surah > 114
ABresult
1X1
011
000
654 0 foreach my $medinah (@medinah) {
655 0 ▶ if ($medinah == $surah) {
Branch: 1 branch
BranchTrueFalseTotal
if ($medinah == $surah) 0 0 0
656 0 return 1; # Revealed in Medinah
657 }
658 }
659 0 return 0; # Revealed in Makkah
660 }
661 #==========================================================
662 0 ▶sub RemoveDiacritic {
Subroutine RemoveDiacritic: not called CC=1 SCAR=6.9
Pod undocumented
663 0 my ($self, $text) = @_;
664  
665 #Windows Arabic (1256)
666 #$Text =~ s/\xF0//g; #ARABIC FATHATAN
667 #$Text =~ s/\xF1//g; #ARABIC DAMMATAN
668 #$Text =~ s/\xF2//g; #ARABIC KASRATAN
669 #$Text =~ s/\xF3//g; #ARABIC FATHA
670 #$Text =~ s/\xF5//g; #ARABIC DAMMA
671 #$Text =~ s/\xF6//g; #ARABIC KASRA
672 #$Text =~ s/\xF8//g; #ARABIC SHADDA
673 #$Text =~ s/\xFA//g; #ARABIC SUKUN
674 0 $text =~ s/\xF0|\xF1|\xF2|\xF3|\xF5|\xF6|\xF8|\xFA//g;
675 #Allah Isolated form: ��� = \x{e1}\x{e1}\x{e5}, = Unicode &#65010; = &#xFDF2; = &#1604;&#1604;&#1607;
676  
677 # 1256 - Uindex - UISOname
678 # F0 064B ARABIC FATHATAN
679 # F1 064C ARABIC DAMMATAN
680 # F2 064D ARABIC KASRATAN
681 # F3 064E ARABIC FATHA
682 # F5 064F ARABIC DAMMA
683 # F6 0650 ARABIC KASRA
684 # F8 0651 ARABIC SHADDA
685 # FA 0652 ARABIC SUKUN
686
687 #Unicode Hex
688 #$Text =~ s/\x{064B}//g;
689 #$Text =~ s/\x{064C}//g;
690 #$Text =~ s/\x{064D}//g;
691 #$Text =~ s/\x{064E}//g;
692 #$Text =~ s/\x{064F}//g;
693 #$Text =~ s/\x{0650}//g;
694 #$Text =~ s/\x{0651}//g;
695 #$Text =~ s/\x{0652}//g;
696
697 #Unicode Decimal
698 #$Text =~ s/\&\#1611\;//g; # 064B , ARABIC FATHATAN
699 #$Text =~ s/\&\#1612\;//g; # 064C , ARABIC DAMMATAN
700 #$Text =~ s/\&\#1613\;//g; # 064D , ARABIC KASRATAN
701 #$Text =~ s/\&\#1614\;//g; # 064E , ARABIC FATHA
702 #$Text =~ s/\&\#1615\;//g; # 064F , ARABIC DAMMA
703 #$Text =~ s/\&\#1616\;//g; # 0650 , ARABIC KASRA
704 #$Text =~ s/\&\#1617\;//g; # 0651 , ARABIC SHADDA
705 #$Text =~ s/\&\#1618\;//g; # 0652 , ARABIC SUKUN
706 #http://www.microsoft.com/typography/unicode/1256.htm
707
708 0 $text =~ s/\&\#1611\;|\&\#1612\;|\&\#1613\;|\&\#1614\;|\&\#1615\;|\&\#1616\;|\&\#1617\;|\&\#1618\;//g;
709 0 return $text;
710 }
711 #==========================================================
712 #==========================================================
713 1 1;
714  
715 =encoding utf-8
716  
717 =head1 NAME
718  
719 Religion::Islam::Quran - Holy Quran book searchable database multi-lingual in utf-8 unicode format
720  
721 =head1 SYNOPSIS
722  
723 #---------------------------------------------------------------
724 use Religion::Islam::Quran;
725 #---------------------------------------------------------------
726 #create new object with default options, Arabic language
727 my $quran = Religion::Islam::Quran->new();
728  
729 # or select the English Language:
730 my $quran = Religion::Islam::Quran->new(Language=>'English');
731
732 # you can also specifiy your own database files path:
733 my $quran = Religion::Islam::Quran->new(DatabasePath => './Quran/mydatabase');
734 #---------------------------------------------------------------
735 #Returns the available Quran databases
736 @Languages = $quran->GetLanguages();
737 #---------------------------------------------------------------
738 # returns all the quran surahs count.
739 $surahs = $quran->SurahCount; # returns 114
740 #---------------------------------------------------------------
741 # returns all the quran ayats count.
742 $ayats = $quran->AyahCount; # returns 6236
743 #---------------------------------------------------------------
744 #returns all surah ayats Quran in an array.
745 @surah = $quran->Surah(1);
746 #---------------------------------------------------------------
747 #returns the number of surah ayats.
748 $surah_number = 1; # 1 to 114
749 $surah_ayats = $quran->SurahAyahCount($surah_number);
750 #---------------------------------------------------------------
751 # returns the surah name using the surah number from 1 to 114.
752 $surah_name = $quran->SurahName($surah_number, $optional_language);
753 #---------------------------------------------------------------
754 # returns Quran text of specific surah ayah.
755 $ayah = $quran->Ayah($surah_number, $ayah_number);
756 #---------------------------------------------------------------
757 # returns Quran text of specific surah ayah range in an array .
758 @ayats = $quran->Ayats($surah_number, $from_ayah, $to_ayah);
759 #---------------------------------------------------------------
760 # returns all the Quran text of specific surah in an array.
761 @ayats = $quran->Surah($surah_number);
762 #---------------------------------------------------------------
763 # returns the names of each surah in the Quran sort order.
764 @surahs_name = $quran->SurahsNames();
765 #---------------------------------------------------------------
766 # returns the ayats number for each surah in the Quran sort order.
767 @surahs_ayats = $quran->SurahsAyats();
768 #---------------------------------------------------------------
769 # search specific Surah for specific text and returns the ayahs numbers
770 @ayats = $quran->SearchSurah($surah, $findwhat);
771 #---------------------------------------------------------------
772 #Remove Diacritic from Arabic Text
773 $TextWithoutDiacritic = $quran->RemoveDiacritic($TextWithDiacritic);
774 #---------------------------------------------------------------
775 #The Wajib Sajdah of the Qur'an
776 #In four Surahs of the Qur'an there are ayats of sajdah that if a person reads one
777 #of these ayats, or if he hears someone else recite one of these ayats, once the
778 #ayat is finished, one must immediately go into sajdah.
779 #Returns the Surah=>Ayah pairs
780 %SajdahCompulsaryAyats = $quran->SajdahCompulsaryAyats();
781 print $quran->IsSajdahCompulsaryAyah($surah, $ayah);
782
783 #The recommended (mustahab) Sajdah of the Qur'an
784 #Returns the Surah=>Ayah pairs
785 %SajdahRecommendedAyats = $quran->SajdahRecommendedAyats();
786 print $quran->IsSajdahRecommendedAyah($surah, $ayah);
787
788 #Surah Number Order of Revelation
789 #Returns surah number=>order of revelation pairs
790 %OrderOfRevelation = $quran->OrderOfRevelation();
791 print "Surah Order Of Revelation: " . $quran->SurahOrderOfRevelation($surah);
792
793 #Where each surah revealed, Mekkah or Medianh
794 #Return 1 for Medinah and 0 for Mekkah
795 print $quran->SurahRevelation($surah);
796  
797 =head1 DESCRIPTION
798  
799 This module contains the full Holy Quran Book database searchable
800 and provides many methods for retriving whole quran, specific surahs, or specific ayats and
801 information about Quran and each surah in different languages and transliterations.
802 Quran database files are simply text files pipe separated each line is formated as:
803  
804 <SurahNumber>|<AyahNumber>|<AyahText><CRLF>
805  
806 Example of Arabic database file first Surah QuranArabic.txt:
807  
808 1|1|بِسْمِ اللّهِ الرَّحْمَنِ الرَّحِيمِ
809 1|2|الْحَمْدُ للّهِ رَبِّ الْعَالَمِينَ
810 1|3|الرَّحْمنِ الرَّحِيمِ
811 1|4|مَلِكِ يَوْمِ الدِّينِ
812 1|5|إِيَّاكَ نَعْبُدُ وإِيَّاكَ نَسْتَعِينُ
813 1|6|اهدِنَا الصِّرَاطَ المُستَقِيمَ
814 1|7|صِرَاطَ الَّذِينَ أَنعَمتَ عَلَيهِمْ غَيرِ المَغضُوبِ عَلَيهِمْ وَلاَ الضَّالِّينَ
815  
816 and the 112th Surah in QuranEnglish.txt:
817  
818 112|1|Say: He is Allah, the One and Only;
819 112|2|Allah, the Eternal, Absolute;
820 112|3|He begetteth not, nor is He begotten;
821 112|4|And there is none like unto Him.
822  
823 Database text files located in the module directory /Religion/Islam/Quran.
824 Default module comes with the Quran Arabic and some other translations.
825 You can download more quran translations and transliterations from www.islamware.com.
826  
827 Languages and databases included with the module are:
828  
829 Albanian
830 Arabic
831 Azerbaijani
832 Chinese
833 Dutch
834 English
835 EnglishUS
836 Finnish
837 French
838 German
839 Harun
840 Indonesian
841 Italian
842 Japanese
843 Latin
844 Malaysian
845 Mexican
846 Persian
847 Poland
848 Portuguese
849 Russian
850 Spanish
851 Swahili
852 Tamil
853 Thai
854 Turkish
855  
856 EnglishTransliteration
857  
858 Surah names are only available in English and Arabic languages.
859  
860 =head2 Methods
861  
862 =head1 SEE ALSO
863  
864 L<Date::HijriDate>
865 L<Religion::Islam::Qibla>
866 L<Religion::Islam::PrayTime>
867 L<Religion::Islam::PrayerTimes>
868  
869 =head1 AUTHOR
870  
871 Ahmed Amin Elsheshtawy, <support@islamware.com> <support@mewsoft.com>
872 Website: http://www.islamware.com http://www.mewsoft.com
873  
874 =head1 COPYRIGHT AND LICENSE
875  
876 Copyright (C) 2006-2013 by Ahmed Amin Elsheshtawy support@islamware.com, support@mewsoft.com
877 L<http://www.islamware.com> L<http://www.mewsoft.com>
878  
879 This library is free software; you can redistribute it and/or modify
880 it under the same terms as Perl itself.
881  
882 =cut
↑ Summary