true religion
Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 601
Religion 1.04
Religion is a Perl module that can generate tracebacks and create and install die() and warn() handlers. more>>
Religion is a Perl module that can generate tracebacks and create and install die() and warn() handlers.
This is a second go at a module to simplify installing die() and warn() handlers, and to make such handlers easier to write and control.
For most people, this just means that if use use Religion; then youll get noticably better error reporting from warn() and die(). This is especially useful if you are using eval().
Religion provides four classes, WarnHandler, DieHandler, WarnPreHandler, and DiePreHandler, that when you construct them return closures that can be stored in variables that in turn get invoked by $SIG{__DIE__} and $SIG{__WARN__}. Note that if Religion is in use, you should not modify $SIG{__DIE__} or $SIG{__WARN__}, unless you are careful about invoking chaining to the old handler.
Religion also provides a TraceBack function, which is used by a DieHandler after you die() to give a better handle on the current scope of your situation, and provide information about where you were, which might influence where you want to go next, either returning back to where you were, or going on to the very last. [Sorry - Ed.]
See below for usage and examples.
USAGE
DieHandler SUB
Invoke like this:
$Die::Handler = new DieHandler sub {
#...
};
where #... contains your handler code. Your handler will receive the following arguments:
$message, $full_message, $level, $eval,
$iline, $ifile, $oline, $ofile, $oscope
$message is the message provided to die(). Note that the default addition of " at FILE line LINE.n" will have been stripped off if it was present. If you want to add such a message back on, feel free to do so with $iline and $ifile.
$full_message) is the message with a scope message added on if there was no newline at the end of $message. Currently, this is not the original message that die() tacked on, but something along the lines of " at line 3 of the eval at line 4 of Foo.pln".
$eval is non-zero if the die() was invoked inside an eval.
The rest of the arguments are explained in the source for Religion::TraceBack. Yes, I need to document these, but not just now, for they are a pain to explain.
Whenever you install a DieHandler, it will automatically store the current value of $Die::Handler so it can chain to it. If you want to install a handler only temporarily, use local().
If your handler returns data using return or by falling off the end, then the items returns will be used to fill back in the argument list, and the next handler in the chain, if any, will be invoked. Dont fall off the end if you dont want to change the error message.
If your handler exits using last, then no further handlers will be invoked, and the program will die immediatly.
If your handler exits using next, then the next handler in the chain will be invoked directly, without giving you a chance to change its arguments as you could if you used return.
If your handler invokes die(), then die() will proceed as if no handlers were installed. If you are inside an eval, then it will exit to the scope enclosing the eval, otherwise it will exit the program.
WarnHandler SUB
Invoke like this:
$Warn::Handler = new WarnHandler sub {
#...
};
For the rest of its explanation, see DieHandler, and subsitute warn() for die(). Note that once the last DieHandler completes (or last is invoked) then execution will return to the code that invoked warn().
DiePreHandler SUB
Invoke like this:
$Die::PreHandler = new DiePreHandler sub {
#...
};
This works identically to $Die::Handler, except that it forms a separate chain that is invoked before the DieHandler chain. Since you can use last to abort all the handlers and die immediately, or change the messages or scope details, this can be useful for modifying data that all future handlers will see, or to dispose of some messages from further handling.
This is even more useful in $Warn::PreHandler, since you can just throw away warnings that you know arent needed.
WarnPreHandler SUB
Invoke like this:
$Warn::PreHandler = new WarnPreHandler sub {
#...
};
This works identically to $Warn::Handler, except that it forms a separate chain that is invoked before the WarnHandler chain. Since you can use last to abort all the handlers and return to the program, or change the messages or scope details, this can be useful for modifying data that all future handlers will see, or to dispose of some messages.
This is very useful, since you can just throw away warnings that you know arent needed.
<<lessThis is a second go at a module to simplify installing die() and warn() handlers, and to make such handlers easier to write and control.
For most people, this just means that if use use Religion; then youll get noticably better error reporting from warn() and die(). This is especially useful if you are using eval().
Religion provides four classes, WarnHandler, DieHandler, WarnPreHandler, and DiePreHandler, that when you construct them return closures that can be stored in variables that in turn get invoked by $SIG{__DIE__} and $SIG{__WARN__}. Note that if Religion is in use, you should not modify $SIG{__DIE__} or $SIG{__WARN__}, unless you are careful about invoking chaining to the old handler.
Religion also provides a TraceBack function, which is used by a DieHandler after you die() to give a better handle on the current scope of your situation, and provide information about where you were, which might influence where you want to go next, either returning back to where you were, or going on to the very last. [Sorry - Ed.]
See below for usage and examples.
USAGE
DieHandler SUB
Invoke like this:
$Die::Handler = new DieHandler sub {
#...
};
where #... contains your handler code. Your handler will receive the following arguments:
$message, $full_message, $level, $eval,
$iline, $ifile, $oline, $ofile, $oscope
$message is the message provided to die(). Note that the default addition of " at FILE line LINE.n" will have been stripped off if it was present. If you want to add such a message back on, feel free to do so with $iline and $ifile.
$full_message) is the message with a scope message added on if there was no newline at the end of $message. Currently, this is not the original message that die() tacked on, but something along the lines of " at line 3 of the eval at line 4 of Foo.pln".
$eval is non-zero if the die() was invoked inside an eval.
The rest of the arguments are explained in the source for Religion::TraceBack. Yes, I need to document these, but not just now, for they are a pain to explain.
Whenever you install a DieHandler, it will automatically store the current value of $Die::Handler so it can chain to it. If you want to install a handler only temporarily, use local().
If your handler returns data using return or by falling off the end, then the items returns will be used to fill back in the argument list, and the next handler in the chain, if any, will be invoked. Dont fall off the end if you dont want to change the error message.
If your handler exits using last, then no further handlers will be invoked, and the program will die immediatly.
If your handler exits using next, then the next handler in the chain will be invoked directly, without giving you a chance to change its arguments as you could if you used return.
If your handler invokes die(), then die() will proceed as if no handlers were installed. If you are inside an eval, then it will exit to the scope enclosing the eval, otherwise it will exit the program.
WarnHandler SUB
Invoke like this:
$Warn::Handler = new WarnHandler sub {
#...
};
For the rest of its explanation, see DieHandler, and subsitute warn() for die(). Note that once the last DieHandler completes (or last is invoked) then execution will return to the code that invoked warn().
DiePreHandler SUB
Invoke like this:
$Die::PreHandler = new DiePreHandler sub {
#...
};
This works identically to $Die::Handler, except that it forms a separate chain that is invoked before the DieHandler chain. Since you can use last to abort all the handlers and die immediately, or change the messages or scope details, this can be useful for modifying data that all future handlers will see, or to dispose of some messages from further handling.
This is even more useful in $Warn::PreHandler, since you can just throw away warnings that you know arent needed.
WarnPreHandler SUB
Invoke like this:
$Warn::PreHandler = new WarnPreHandler sub {
#...
};
This works identically to $Warn::Handler, except that it forms a separate chain that is invoked before the WarnHandler chain. Since you can use last to abort all the handlers and return to the program, or change the messages or scope details, this can be useful for modifying data that all future handlers will see, or to dispose of some messages.
This is very useful, since you can just throw away warnings that you know arent needed.
Download (0.005MB)
Added: 2007-05-24 License: Perl Artistic License Price:
883 downloads
Religion::Islam::Quran 1.0
Religion::Islam::Quran - Holy Quran book searchable database multi-lingual in both text and unicode formats. more>>
Religion::Islam::Quran - Holy Quran book searchable database multi-lingual in both text and unicode formats.
SYNOPSIS
#---------------------------------------------------------------
use Religion::Islam::Quran;
#---------------------------------------------------------------
#create new object with default options, Arabic language, none unicode
my $quran = Religion::Islam::Quran->new();
# or for unicode format and select the Arabic Language:
my $quran = Religion::Islam::Quran->new(Unicode => 1, Language=>Arabic);
# you can also specifiy your own database files path:
my $quran = Religion::Islam::Quran->new(DatabasePath => ./Quran/mydatabase);
#---------------------------------------------------------------
#Returns the available Quran databases
@Languages = $quran->GetLanguages();
#---------------------------------------------------------------
# returns all the quran surahs count.
$surahs = $quran->SurahCount; # returns 114
#---------------------------------------------------------------
# returns all the quran ayats count.
$ayats = $quran->AyahCount; # returns 6236
#---------------------------------------------------------------
#returns all surah ayats Quran in an array.
@surah = $quran->Surah(1);
#---------------------------------------------------------------
#returns the number of surah ayats.
$surah_number = 1; # 1 to 114
$surah_ayats = $quran->SurahAyahCount($surah_number);
#---------------------------------------------------------------
# returns the surah name using the surah number from 1 to 114.
$surah_name = $quran->SurahName($surah_number);
#---------------------------------------------------------------
# returns Quran text of specific surah ayah .
$ayah = $quran->Ayah($surah_number, $ayah_number);
#---------------------------------------------------------------
# returns Quran text of specific surah ayah range in an array .
@ayats = $quran->Ayats($surah_number, $from_ayah, $to_ayah);
#---------------------------------------------------------------
# returns all the Quran text of specific surah in an array.
@ayats = $quran->Surah($surah_number);
#---------------------------------------------------------------
# returns the surah number using the surah name in Quran sort.
$surah_number = $quran->surah_number($surah_name);
#---------------------------------------------------------------
# returns the names of each surah in the Quran sort order.
@surahs_name = $quran->SurahsNames();
#---------------------------------------------------------------
# returns the ayats number for each surah in the Quran sort order.
@surahs_ayats = $quran->SurahsAyats();
#---------------------------------------------------------------
# search specific Surah for specific text and returns the ayahs numbers
@ayats = $quran->SearchSurah($surah, $findwhat);
#---------------------------------------------------------------
#Remove Diacritic from Arabic Text
$TextWithoutDiacritic = $quran->RemoveDiacritic($TextWithDiacritic);
#---------------------------------------------------------------
#The Wajib Sajdah of the Quran
#In four Surahs of the Quran 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.
#Returns the Surah=>Ayah pairs
%SajdahCompulsaryAyats = $quran->SajdahCompulsaryAyats();
print $quran->IsSajdahCompulsaryAyah($surah, $ayah);
#The recommended (mustahab) Sajdah of the Quran
#Returns the Surah=>Ayah pairs
%SajdahRecommendedAyats = $quran->SajdahRecommendedAyats();
print $quran->IsSajdahRecommendedAyah($surah, $ayah);
#Surah Number Order of Revelation
#Returns surah number=>order of revelation pairs
%OrderOfRevelation = $quran->OrderOfRevelation();
print "Surah Order Of Revelation: " . $quran->SurahOrderOfRevelation($surah);
#Where each surah revealed, Mekkah or Medianh
#Return 1 for Medinah and 0 for Mekkah
print $quran->SurahRevelation($surah);
print $quran->SurahNameArabicUnicode($surah);
This module contains the full Holy Quran Book database searchable and provides many methods for retriving whole quran, specific surahs, or specific ayats and information about Quran and each surah in different languages and transliterations. Quran database files are simply text files pipe separated each line is formated as:
< SurahNumber >|< AyahNumber >|< AyahText >< CRLF >
Database text files located in the module directory /Religion/Islam/Quran. Default module comes with the Quran Arabic and some other translations. You can download more quran translations and transliterations from www.islamware.com.
<<lessSYNOPSIS
#---------------------------------------------------------------
use Religion::Islam::Quran;
#---------------------------------------------------------------
#create new object with default options, Arabic language, none unicode
my $quran = Religion::Islam::Quran->new();
# or for unicode format and select the Arabic Language:
my $quran = Religion::Islam::Quran->new(Unicode => 1, Language=>Arabic);
# you can also specifiy your own database files path:
my $quran = Religion::Islam::Quran->new(DatabasePath => ./Quran/mydatabase);
#---------------------------------------------------------------
#Returns the available Quran databases
@Languages = $quran->GetLanguages();
#---------------------------------------------------------------
# returns all the quran surahs count.
$surahs = $quran->SurahCount; # returns 114
#---------------------------------------------------------------
# returns all the quran ayats count.
$ayats = $quran->AyahCount; # returns 6236
#---------------------------------------------------------------
#returns all surah ayats Quran in an array.
@surah = $quran->Surah(1);
#---------------------------------------------------------------
#returns the number of surah ayats.
$surah_number = 1; # 1 to 114
$surah_ayats = $quran->SurahAyahCount($surah_number);
#---------------------------------------------------------------
# returns the surah name using the surah number from 1 to 114.
$surah_name = $quran->SurahName($surah_number);
#---------------------------------------------------------------
# returns Quran text of specific surah ayah .
$ayah = $quran->Ayah($surah_number, $ayah_number);
#---------------------------------------------------------------
# returns Quran text of specific surah ayah range in an array .
@ayats = $quran->Ayats($surah_number, $from_ayah, $to_ayah);
#---------------------------------------------------------------
# returns all the Quran text of specific surah in an array.
@ayats = $quran->Surah($surah_number);
#---------------------------------------------------------------
# returns the surah number using the surah name in Quran sort.
$surah_number = $quran->surah_number($surah_name);
#---------------------------------------------------------------
# returns the names of each surah in the Quran sort order.
@surahs_name = $quran->SurahsNames();
#---------------------------------------------------------------
# returns the ayats number for each surah in the Quran sort order.
@surahs_ayats = $quran->SurahsAyats();
#---------------------------------------------------------------
# search specific Surah for specific text and returns the ayahs numbers
@ayats = $quran->SearchSurah($surah, $findwhat);
#---------------------------------------------------------------
#Remove Diacritic from Arabic Text
$TextWithoutDiacritic = $quran->RemoveDiacritic($TextWithDiacritic);
#---------------------------------------------------------------
#The Wajib Sajdah of the Quran
#In four Surahs of the Quran 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.
#Returns the Surah=>Ayah pairs
%SajdahCompulsaryAyats = $quran->SajdahCompulsaryAyats();
print $quran->IsSajdahCompulsaryAyah($surah, $ayah);
#The recommended (mustahab) Sajdah of the Quran
#Returns the Surah=>Ayah pairs
%SajdahRecommendedAyats = $quran->SajdahRecommendedAyats();
print $quran->IsSajdahRecommendedAyah($surah, $ayah);
#Surah Number Order of Revelation
#Returns surah number=>order of revelation pairs
%OrderOfRevelation = $quran->OrderOfRevelation();
print "Surah Order Of Revelation: " . $quran->SurahOrderOfRevelation($surah);
#Where each surah revealed, Mekkah or Medianh
#Return 1 for Medinah and 0 for Mekkah
print $quran->SurahRevelation($surah);
print $quran->SurahNameArabicUnicode($surah);
This module contains the full Holy Quran Book database searchable and provides many methods for retriving whole quran, specific surahs, or specific ayats and information about Quran and each surah in different languages and transliterations. Quran database files are simply text files pipe separated each line is formated as:
< SurahNumber >|< AyahNumber >|< AyahText >< CRLF >
Database text files located in the module directory /Religion/Islam/Quran. Default module comes with the Quran Arabic and some other translations. You can download more quran translations and transliterations from www.islamware.com.
Download (1.7MB)
Added: 2007-05-24 License: Perl Artistic License Price:
891 downloads
Religion::Islam::Qibla 1.02
Religion::Islam::Qibla is a Perl module that calculates the Muslim Qiblah Direction, Great Circle Distance and more... more>>
Religion::Islam::Qibla is a Perl module that calculates the Muslim Qiblah Direction, Great Circle Distance, and Great Circle Direction.
SYNOPSIS
use Religion::Islam::Qibla;
#create new object with default options, Destination point is Kabah Lat=21 Deg N, Long 40 Deg E
my $qibla = Religion::Islam::Qibla->new();
# OR
#create new object and set your destination point Latitude and/or Longitude
my $qibla = Religion::Islam::Qibla->new(DestLat => 21, DestLong => 40);
# Calculate the Qibla direction From North Clocklwise for Cairo : Lat=30.1, Long=31.3
my $Latitude = 30.1;
my $Longitude = 31.3;
my $QiblaDirection = $qibla->QiblaDirection($Latitude, $Longitude);
print "The Qibla Direction for $Latitude and $Longitude From North Clocklwise is: " . $QiblaDirection ."n";
# Calculates the distance between any two points on the Earth
my $OrigLat = 31; my $DestLat = 21; my $OrigLong = 31.3; $DestLong = 40;
my $distance = $qibla->GreatCircleDistance($OrigLat , $DestLat, $OrigLong, $DestLong);
print "The distance is: $distance n";
# Calculates the direction from one point to another on the Earth. Great Circle Bearing
my $direction = $qibla->GreatCircleDirection($OrigLat, $DestLat, $OrigLong, $DestLong, $Distance);
print "The direction is: $direction n";
# You can get and set the distination point Latitude and Longitude
# $qibla->DestLat(21); # set distination Latitude
# $qibla->DestLong(40); # set distincatin Longitude
print "Destination Latitude:" . $qibla->DestLat();
print "Destination Longitude:" . $qibla->DestLong();
<<lessSYNOPSIS
use Religion::Islam::Qibla;
#create new object with default options, Destination point is Kabah Lat=21 Deg N, Long 40 Deg E
my $qibla = Religion::Islam::Qibla->new();
# OR
#create new object and set your destination point Latitude and/or Longitude
my $qibla = Religion::Islam::Qibla->new(DestLat => 21, DestLong => 40);
# Calculate the Qibla direction From North Clocklwise for Cairo : Lat=30.1, Long=31.3
my $Latitude = 30.1;
my $Longitude = 31.3;
my $QiblaDirection = $qibla->QiblaDirection($Latitude, $Longitude);
print "The Qibla Direction for $Latitude and $Longitude From North Clocklwise is: " . $QiblaDirection ."n";
# Calculates the distance between any two points on the Earth
my $OrigLat = 31; my $DestLat = 21; my $OrigLong = 31.3; $DestLong = 40;
my $distance = $qibla->GreatCircleDistance($OrigLat , $DestLat, $OrigLong, $DestLong);
print "The distance is: $distance n";
# Calculates the direction from one point to another on the Earth. Great Circle Bearing
my $direction = $qibla->GreatCircleDirection($OrigLat, $DestLat, $OrigLong, $DestLong, $Distance);
print "The direction is: $direction n";
# You can get and set the distination point Latitude and Longitude
# $qibla->DestLat(21); # set distination Latitude
# $qibla->DestLong(40); # set distincatin Longitude
print "Destination Latitude:" . $qibla->DestLat();
print "Destination Longitude:" . $qibla->DestLong();
Download (0.004MB)
Added: 2007-05-23 License: Perl Artistic License Price:
891 downloads
Group Shell 0.2
Group Shell is a tool to aggregate several remote shells into one. more>>
Group Shell is a tool to aggregate several remote shells into one. It is used to launch an interactive remote shell on many machines at once. Group Shell is written in Python and requires Python ≥ 2.4.
There is a control shell accessible with Ctrl-C that is used to list some information about the current remote shells. It also allows common terminal manipulations like sending a Ctrl-C, Ctrl-Z, Ctrl-D …
The prompt shows the number of listening shells and the number of active shell. A shell is said to be listening if its prompt has returned and it is accepting commands, active shells are those whose connection is still alive. Shells can be individually enabled and disabled.
Here is the transcript of a sample session:
[g ~/gsh]$ ./gsh.py machine{0-9}
[10/10]> date
machine4: ven nov 10 23:26:36 CET 2006
machine7: ven nov 10 23:26:36 CET 2006
machine3: ven nov 10 23:26:36 CET 2006
machine5: ven nov 10 23:26:36 CET 2006
machine9: ven nov 10 23:26:36 CET 2006
machine0: ven nov 10 23:26:36 CET 2006
machine2: ven nov 10 23:26:36 CET 2006
machine1: ven nov 10 23:26:37 CET 2006
machine6: ven nov 10 23:26:37 CET 2006
machine8: ven nov 10 23:26:37 CET 2006
[10/10]>
Now, Ctrl-C is pressed, it triggers the control shell.
(Cmd) help
Documented commands (type help < topic >):
EOF enable list send_eof set_print_first
continue get_print_first quit send_sigint unset_print_first
disable help reconnect send_sigtstp
(Cmd) list
machine0 fd:3 r:3 w:0 active:True enabled:True idle
machine1 fd:4 r:3 w:0 active:True enabled:True idle
machine2 fd:5 r:3 w:0 active:True enabled:True idle
machine3 fd:6 r:3 w:0 active:True enabled:True idle
machine4 fd:7 r:3 w:0 active:True enabled:True idle
machine5 fd:8 r:3 w:0 active:True enabled:True idle
machine6 fd:9 r:3 w:0 active:True enabled:True idle
machine7 fd:10 r:3 w:0 active:True enabled:True idle
machine8 fd:11 r:3 w:0 active:True enabled:True idle
machine9 fd:12 r:3 w:0 active:True enabled:True idle
10 active shells, 0 dead shells, total: 10
(Cmd) quit
[g ~/gsh]$
<<lessThere is a control shell accessible with Ctrl-C that is used to list some information about the current remote shells. It also allows common terminal manipulations like sending a Ctrl-C, Ctrl-Z, Ctrl-D …
The prompt shows the number of listening shells and the number of active shell. A shell is said to be listening if its prompt has returned and it is accepting commands, active shells are those whose connection is still alive. Shells can be individually enabled and disabled.
Here is the transcript of a sample session:
[g ~/gsh]$ ./gsh.py machine{0-9}
[10/10]> date
machine4: ven nov 10 23:26:36 CET 2006
machine7: ven nov 10 23:26:36 CET 2006
machine3: ven nov 10 23:26:36 CET 2006
machine5: ven nov 10 23:26:36 CET 2006
machine9: ven nov 10 23:26:36 CET 2006
machine0: ven nov 10 23:26:36 CET 2006
machine2: ven nov 10 23:26:36 CET 2006
machine1: ven nov 10 23:26:37 CET 2006
machine6: ven nov 10 23:26:37 CET 2006
machine8: ven nov 10 23:26:37 CET 2006
[10/10]>
Now, Ctrl-C is pressed, it triggers the control shell.
(Cmd) help
Documented commands (type help < topic >):
EOF enable list send_eof set_print_first
continue get_print_first quit send_sigint unset_print_first
disable help reconnect send_sigtstp
(Cmd) list
machine0 fd:3 r:3 w:0 active:True enabled:True idle
machine1 fd:4 r:3 w:0 active:True enabled:True idle
machine2 fd:5 r:3 w:0 active:True enabled:True idle
machine3 fd:6 r:3 w:0 active:True enabled:True idle
machine4 fd:7 r:3 w:0 active:True enabled:True idle
machine5 fd:8 r:3 w:0 active:True enabled:True idle
machine6 fd:9 r:3 w:0 active:True enabled:True idle
machine7 fd:10 r:3 w:0 active:True enabled:True idle
machine8 fd:11 r:3 w:0 active:True enabled:True idle
machine9 fd:12 r:3 w:0 active:True enabled:True idle
10 active shells, 0 dead shells, total: 10
(Cmd) quit
[g ~/gsh]$
Download (0.024MB)
Added: 2007-08-02 License: GPL (GNU General Public License) Price:
813 downloads
Religion::Islam::PrayerTimes 1.02
Religion::Islam::PrayerTimes is a Perl module that calculates Muslim Prayers Times and Sunrise. more>>
Religion::Islam::PrayerTimes is a Perl module that calculates Muslim Prayers Times and Sunrise.
SYNOPSIS
use Religion::Islam::PrayerTimes;
#create new object with default options
my $prayer = Religion::Islam::PrayerTimes->new();
#Juristic Methods:
# 1 = Standard (Imams Shafii, Hanbali, and Maliki),
#2 = Hanafi
#The difference is in the Aser time only
$prayer->JuristicMethod(1);
# Calculation Method
#1: Umm Al-Qura Committee
#2: Muslim World League
#3: Egyptian General Authority of Survey
#4: University Of Islamic Sciences, Karachi
#5: ISNA, Islamic Society of North America
$prayer->CalculationMethod(3);
# Q. What is daylight saving? Ans. Many countries try to adopt their work time by subtracting
# from their clocks one hour in the Fall and Winter seasons.
$prayer->DaylightSaving(1);
#print "DaylightSaving: ". $prayer->DaylightSaving() ."n";
# set the location to clculate prayer times for.
# for Cairo, Egypt:
# http://heavens-above.com/countries.asp
$prayer->PrayerLocation(
Latitude => 30.050,
Longitude => 31.250,
Altitude => 24,
TimeZone => 2
);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$mon++; $year += 1900;
#Adjust the Gregorian Dates by making sure that the month lengths
#are correct if not so take the extra days to next month or year.
my ($yg0, $mg0, $dg0) = $prayer->GDateAjust($year, $mon, $mday);
# Now calculate the prayer times. Times returns in hours decimal format
#%result = $prayer->PrayerTimes($year, $mon, $mday);
%result = $prayer->PrayerTimes($yg0, $mg0, $dg0);
#print "Fajr: " . $result{Fajr} . "n";
#print "Sunrise: " . $result{Sunrise} . "n";
#print "Zohar: " . $result{Zohar} . "n";
#print "Aser: " . $result{Aser} . "n";
#print "Maghrib: " . $result{Maghrib} . "n";
#print "Isha: " . $result{Isha} . "n";
#print "Fajir Rabita: " . $result{FajirRabita} . "n"; #Fajer using exact Rabita method for places >48
#print "Isha Rabita: " . $result{IshaRabita} . "n"; #Ash using exact Rabita method for places >48
#print "Eid Prayer Time: " . $result{Eid} . "n"; #Eid Prayer Time
#print "n";
# set time mode for 12 or 24 hour for FormatTime function.
$prayer->TimeMode(1);
#print time formated
#print "TimeMode: " . $prayer->TimeMode() ."n";
my ($h, $m, $ap);
($h, $m, $ap) = $prayer->FormatTime($result{Fajr});
print "Fajr: $h:$m $apn";
($h, $m, $ap) = $prayer->FormatTime($result{Sunrise});
print "Sunrise: $h:$m $apn";
($h, $m, $ap) = $prayer->FormatTime($result{Zohar});
print "Zohar: $h:$m $apn";
($h, $m, $ap) = $prayer->FormatTime($result{Aser});
print "Aser: $h:$m $apn";
($h, $m, $ap) = $prayer->FormatTime($result{Maghrib});
print "Maghrib: $h:$m $apn";
($h, $m, $ap) = $prayer->FormatTime($result{Isha});
print "Isha: $h:$m $apn";
#($h, $m, $ap) = $prayer->FormatTime($result{FajirRabita});
#print "Fajir Rabita: $h:$m $apn"; #Fajer using exact Rabita method for places >48
#($h, $m, $ap) = $prayer->FormatTime($result{IshaRabita});
#print "Isha Rabita: $h:$m $apn"; #Ash using exact Rabita method for places >48
#($h, $m, $ap) = $prayer->FormatTime($result{Eid});
#print "Eid Prayer Time: $h:$m $apn"; #Eid Prayer Time
<<lessSYNOPSIS
use Religion::Islam::PrayerTimes;
#create new object with default options
my $prayer = Religion::Islam::PrayerTimes->new();
#Juristic Methods:
# 1 = Standard (Imams Shafii, Hanbali, and Maliki),
#2 = Hanafi
#The difference is in the Aser time only
$prayer->JuristicMethod(1);
# Calculation Method
#1: Umm Al-Qura Committee
#2: Muslim World League
#3: Egyptian General Authority of Survey
#4: University Of Islamic Sciences, Karachi
#5: ISNA, Islamic Society of North America
$prayer->CalculationMethod(3);
# Q. What is daylight saving? Ans. Many countries try to adopt their work time by subtracting
# from their clocks one hour in the Fall and Winter seasons.
$prayer->DaylightSaving(1);
#print "DaylightSaving: ". $prayer->DaylightSaving() ."n";
# set the location to clculate prayer times for.
# for Cairo, Egypt:
# http://heavens-above.com/countries.asp
$prayer->PrayerLocation(
Latitude => 30.050,
Longitude => 31.250,
Altitude => 24,
TimeZone => 2
);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$mon++; $year += 1900;
#Adjust the Gregorian Dates by making sure that the month lengths
#are correct if not so take the extra days to next month or year.
my ($yg0, $mg0, $dg0) = $prayer->GDateAjust($year, $mon, $mday);
# Now calculate the prayer times. Times returns in hours decimal format
#%result = $prayer->PrayerTimes($year, $mon, $mday);
%result = $prayer->PrayerTimes($yg0, $mg0, $dg0);
#print "Fajr: " . $result{Fajr} . "n";
#print "Sunrise: " . $result{Sunrise} . "n";
#print "Zohar: " . $result{Zohar} . "n";
#print "Aser: " . $result{Aser} . "n";
#print "Maghrib: " . $result{Maghrib} . "n";
#print "Isha: " . $result{Isha} . "n";
#print "Fajir Rabita: " . $result{FajirRabita} . "n"; #Fajer using exact Rabita method for places >48
#print "Isha Rabita: " . $result{IshaRabita} . "n"; #Ash using exact Rabita method for places >48
#print "Eid Prayer Time: " . $result{Eid} . "n"; #Eid Prayer Time
#print "n";
# set time mode for 12 or 24 hour for FormatTime function.
$prayer->TimeMode(1);
#print time formated
#print "TimeMode: " . $prayer->TimeMode() ."n";
my ($h, $m, $ap);
($h, $m, $ap) = $prayer->FormatTime($result{Fajr});
print "Fajr: $h:$m $apn";
($h, $m, $ap) = $prayer->FormatTime($result{Sunrise});
print "Sunrise: $h:$m $apn";
($h, $m, $ap) = $prayer->FormatTime($result{Zohar});
print "Zohar: $h:$m $apn";
($h, $m, $ap) = $prayer->FormatTime($result{Aser});
print "Aser: $h:$m $apn";
($h, $m, $ap) = $prayer->FormatTime($result{Maghrib});
print "Maghrib: $h:$m $apn";
($h, $m, $ap) = $prayer->FormatTime($result{Isha});
print "Isha: $h:$m $apn";
#($h, $m, $ap) = $prayer->FormatTime($result{FajirRabita});
#print "Fajir Rabita: $h:$m $apn"; #Fajer using exact Rabita method for places >48
#($h, $m, $ap) = $prayer->FormatTime($result{IshaRabita});
#print "Isha Rabita: $h:$m $apn"; #Ash using exact Rabita method for places >48
#($h, $m, $ap) = $prayer->FormatTime($result{Eid});
#print "Eid Prayer Time: $h:$m $apn"; #Eid Prayer Time
Download (0.015MB)
Added: 2007-05-24 License: Perl Artistic License Price:
893 downloads
JBooleanExpression 1.2
JBooleanExpression is a simple Java API to evaluate a Boolean String Expression. more>>
JBooleanExpression is a simple Java API to evaluate a Boolean String Expression like "!true&&false||true" (parse a Boolean String Expression to a boolean primitive type).
Enhancements:
- Bugs were fixed.
- A demo class was added.
<<lessEnhancements:
- Bugs were fixed.
- A demo class was added.
Download (0.014MB)
Added: 2006-03-14 License: Other/Proprietary License with Source Price:
1322 downloads
Elixir 0.3.0
Elixir is a declarative layer on top of SQLAlchemy. more>>
Elixir is a declarative layer on top of SQLAlchemy. The project is a fairly thin wrapper, which provides the ability to define model objects following the Active Record design pattern, and using a DSL syntax similar to that of the Ruby on Rails ActiveRecord system.
Elixir does not intend to replace SQLAlchemys core features, but instead focuses on providing a simpler syntax for defining model objects when you do not need the full expressiveness of SQLAlchemys manual mapper definitions.
Examples:
The Elixir source distribution includes a sample web application that uses the TurboGears web application framework. The application builds upon the tutorials Movie model to create a simple store for buying movies.
The Video Store sample application also includes an example of how to use Elixir with the TurboGears "identity" framework for security and authorization. If you are planning to use Elixir with your TurboGears application, and need to support authorization using identity, you can use this model as a basis:
from turbogears.database import metadata, session
from elixir import Unicode, DateTime, String, Integer
from elixir import Entity, has_field, using_options
from elixir import has_many, belongs_to, has_and_belongs_to_many
from sqlalchemy import ForeignKey
from datetime import datetime
class Visit(Entity):
has_field(visit_key, String(40), primary_key=True)
has_field(created, DateTime, nullable=False, default=datetime.now)
has_field(expiry, DateTime)
using_options(tablename=visit)
@classmethod
def lookup_visit(cls, visit_key):
return Visit.get(visit_key)
class VisitIdentity(Entity):
has_field(visit_key, String(40), primary_key=True)
has_field(user_id, Integer, ForeignKey(tg_user.user_id, name=user_id_fk, use_alter=True), index=True)
using_options(tablename=visit_identity)
class Group(Entity):
has_field(group_id, Integer, primary_key=True)
has_field(group_name, Unicode(16), unique=True)
has_field(display_name, Unicode(255)),
has_field(created, DateTime, default=datetime.now)
has_and_belongs_to_many(users, of_kind=User, inverse=groups)
has_and_belongs_to_many(permissions, of_kind=Permission, inverse=groups)
using_options(tablename=tg_group)
class User(Entity):
has_field(user_id, Integer, primary_key=True)
has_field(user_name, Unicode(16), unique=True)
has_field(email_address, Unicode(255), unique=True)
has_field(display_name, Unicode(255))
has_field(password, Unicode(40))
has_field(created, DateTime, default=datetime.now)
has_and_belongs_to_many(groups, of_kind=Group, inverse=users)
using_options(tablename=tg_user)
@property
def permissions(self):
perms = set()
for g in self.groups:
perms = perms | set(g.permissions)
return perms
class Permission(Entity):
has_field(permission_id, Integer, primary_key=True)
has_field(permission_name, Unicode(16), unique=True)
has_field(description, Unicode(255))
has_and_belongs_to_many(groups, of_kind=Group, inverse=permissions)
using_options(tablename=permission)
More Elixir examples are coming soon, and we would appreciate any additional sample applications that you could provide to illustrate more complex mappings.
<<lessElixir does not intend to replace SQLAlchemys core features, but instead focuses on providing a simpler syntax for defining model objects when you do not need the full expressiveness of SQLAlchemys manual mapper definitions.
Examples:
The Elixir source distribution includes a sample web application that uses the TurboGears web application framework. The application builds upon the tutorials Movie model to create a simple store for buying movies.
The Video Store sample application also includes an example of how to use Elixir with the TurboGears "identity" framework for security and authorization. If you are planning to use Elixir with your TurboGears application, and need to support authorization using identity, you can use this model as a basis:
from turbogears.database import metadata, session
from elixir import Unicode, DateTime, String, Integer
from elixir import Entity, has_field, using_options
from elixir import has_many, belongs_to, has_and_belongs_to_many
from sqlalchemy import ForeignKey
from datetime import datetime
class Visit(Entity):
has_field(visit_key, String(40), primary_key=True)
has_field(created, DateTime, nullable=False, default=datetime.now)
has_field(expiry, DateTime)
using_options(tablename=visit)
@classmethod
def lookup_visit(cls, visit_key):
return Visit.get(visit_key)
class VisitIdentity(Entity):
has_field(visit_key, String(40), primary_key=True)
has_field(user_id, Integer, ForeignKey(tg_user.user_id, name=user_id_fk, use_alter=True), index=True)
using_options(tablename=visit_identity)
class Group(Entity):
has_field(group_id, Integer, primary_key=True)
has_field(group_name, Unicode(16), unique=True)
has_field(display_name, Unicode(255)),
has_field(created, DateTime, default=datetime.now)
has_and_belongs_to_many(users, of_kind=User, inverse=groups)
has_and_belongs_to_many(permissions, of_kind=Permission, inverse=groups)
using_options(tablename=tg_group)
class User(Entity):
has_field(user_id, Integer, primary_key=True)
has_field(user_name, Unicode(16), unique=True)
has_field(email_address, Unicode(255), unique=True)
has_field(display_name, Unicode(255))
has_field(password, Unicode(40))
has_field(created, DateTime, default=datetime.now)
has_and_belongs_to_many(groups, of_kind=Group, inverse=users)
using_options(tablename=tg_user)
@property
def permissions(self):
perms = set()
for g in self.groups:
perms = perms | set(g.permissions)
return perms
class Permission(Entity):
has_field(permission_id, Integer, primary_key=True)
has_field(permission_name, Unicode(16), unique=True)
has_field(description, Unicode(255))
has_and_belongs_to_many(groups, of_kind=Group, inverse=permissions)
using_options(tablename=permission)
More Elixir examples are coming soon, and we would appreciate any additional sample applications that you could provide to illustrate more complex mappings.
Download (MB)
Added: 2007-03-28 License: MIT/X Consortium License Price:
941 downloads
RBrainz 0.3.0
RBrainz is a Ruby client library to query the MusicBrainz database using the MusicBrainz XML web service. more>>
RBrainz is a Ruby client library to query the MusicBrainz database using the MusicBrainz XML web service.
RBrainz follows the design of the MusicBrainz client library reference implementation and supports the MusicBrainz XML Metadata Schema Version 1.2.
Usage:
A simple example on how to use RBrainz is shown below. For more detailed instructions see the API documentation.
require rbrainz
include MusicBrainz
# With the ArtistInclude object we can control what
# kind of information the MusicBrainz server will
# include in its answer.
artist_includes = Webservice::ArtistIncludes.new(
:aliases => true,
:releases => [Album, Official],
:artist_rels => true,
:release_rels => true,
:track_rels => true,
:label_rels => true,
:url_rels => true
)
# Query the webservice for the artist with a given ID.
# The result will contain all the information
# specified in artist_includes.
query = Webservice::Query.new
id = c0b2500e-0cef-4130-869d-732b23ed9df5
artist = query.get_artist_by_id(id, artist_includes)
# Display the fetched artist data together with
# all release titles.
print<<less
RBrainz follows the design of the MusicBrainz client library reference implementation and supports the MusicBrainz XML Metadata Schema Version 1.2.
Usage:
A simple example on how to use RBrainz is shown below. For more detailed instructions see the API documentation.
require rbrainz
include MusicBrainz
# With the ArtistInclude object we can control what
# kind of information the MusicBrainz server will
# include in its answer.
artist_includes = Webservice::ArtistIncludes.new(
:aliases => true,
:releases => [Album, Official],
:artist_rels => true,
:release_rels => true,
:track_rels => true,
:label_rels => true,
:url_rels => true
)
# Query the webservice for the artist with a given ID.
# The result will contain all the information
# specified in artist_includes.
query = Webservice::Query.new
id = c0b2500e-0cef-4130-869d-732b23ed9df5
artist = query.get_artist_by_id(id, artist_includes)
# Display the fetched artist data together with
# all release titles.
print<<less
Download (0.070MB)
Added: 2007-08-13 License: BSD License Price:
803 downloads
Oligopoly RC1
Oligopoly is a Monopoly-like game as a Java applet. more>>
Oligopoly project is a Monopoly-like game as a Java applet.
Oligopoly is a Monopoly-like game as a Java applet, directly playable from the Internet. Its written in Java and the object design is very true to the game. It should be easy to modify.
It comes with nice graphics and is quite fun, although it lacks many features of the original game. It is currently only in German.
<<lessOligopoly is a Monopoly-like game as a Java applet, directly playable from the Internet. Its written in Java and the object design is very true to the game. It should be easy to modify.
It comes with nice graphics and is quite fun, although it lacks many features of the original game. It is currently only in German.
Download (0.047MB)
Added: 2007-01-12 License: GPL (GNU General Public License) Price:
1019 downloads
GStreamer 0.09
GStreamer is a Perl interface to the GStreamer library. more>>
GStreamer is a Perl interface to the GStreamer library.
SYNOPSIS
use GStreamer -init;
my $loop = Glib::MainLoop -> new();
# set up
my $play = GStreamer::ElementFactory -> make("playbin", "play");
$play -> set(uri => Glib::filename_to_uri $file, "localhost");
$play -> get_bus() -> add_watch(&my_bus_callback, $loop);
$play -> set_state("playing");
# run
$loop -> run();
# clean up
$play -> set_state("null");
sub my_bus_callback {
my ($bus, $message, $loop) = @_;
if ($message -> type & "error") {
warn $message -> error;
$loop -> quit();
}
elsif ($message -> type & "eos") {
$loop -> quit();
}
# remove message from the queue
return TRUE;
}
<<lessSYNOPSIS
use GStreamer -init;
my $loop = Glib::MainLoop -> new();
# set up
my $play = GStreamer::ElementFactory -> make("playbin", "play");
$play -> set(uri => Glib::filename_to_uri $file, "localhost");
$play -> get_bus() -> add_watch(&my_bus_callback, $loop);
$play -> set_state("playing");
# run
$loop -> run();
# clean up
$play -> set_state("null");
sub my_bus_callback {
my ($bus, $message, $loop) = @_;
if ($message -> type & "error") {
warn $message -> error;
$loop -> quit();
}
elsif ($message -> type & "eos") {
$loop -> quit();
}
# remove message from the queue
return TRUE;
}
Download (0.063MB)
Added: 2007-05-11 License: Perl Artistic License Price:
906 downloads
True Color Picker 2007-07-06
True Color Picker is a PHP class that can be used to present a palette to let the user pick colors. more>>
True Color Picker is a PHP class that can be used to present a palette to let the user pick colors.
It displays an image with all the tones for the user to pick by clicking in an image point with the desired tone similar to Photoshop.
It uses AJAX to update the picker boxes without reloading the page.
<<lessIt displays an image with all the tones for the user to pick by clicking in an image point with the desired tone similar to Photoshop.
It uses AJAX to update the picker boxes without reloading the page.
Download (MB)
Added: 2007-07-13 License: Freely Distributable Price:
837 downloads
Struct::Compare 1.0.1
Struct::Compare is a recursive diff for perl structures. more>>
Struct::Compare is a recursive diff for perl structures.
SYNOPSIS
use Struct::Compare;
my $is_different = compare($ref1, $ref2);
Compares two values of any type and structure and returns true if they are the same. It does a deep comparison of the structures, so a hash of a hash of a whatever will be compared correctly.
This is especially useful for writing unit tests for your modules!
PUBLIC FUNCTIONS
$bool = compare($var1, $var2)
Recursively compares $var1 to $var2, returning false if either structure is different than the other at any point. If both are undefined, it returns true as well, because that is considered equal.
<<lessSYNOPSIS
use Struct::Compare;
my $is_different = compare($ref1, $ref2);
Compares two values of any type and structure and returns true if they are the same. It does a deep comparison of the structures, so a hash of a hash of a whatever will be compared correctly.
This is especially useful for writing unit tests for your modules!
PUBLIC FUNCTIONS
$bool = compare($var1, $var2)
Recursively compares $var1 to $var2, returning false if either structure is different than the other at any point. If both are undefined, it returns true as well, because that is considered equal.
Download (0.003MB)
Added: 2007-02-12 License: Perl Artistic License Price:
984 downloads
XTrader 2006.05
XTrader is a stock chart and technical analysis program. more>>
XTrader is a stock chart and technical analysis application. A simple portfolio module is also included for keeping tracks of your investments.
Main features:
- You can have unlimited number of workspaces with their own settings
- The database is a single sqlite3 database file
- SMA (Moving Average)
- ESMA (Exponential Moving Average)
- MACD
- Momentum
- RSI (Relative Strength Index)
- Stochastics
- ATR (Average True Range)
- Bollinger
- Standard Deviation
- Price List Report
- Price Change Report
- Portfolio Performance Report
- Portfolio Value Report
<<lessMain features:
- You can have unlimited number of workspaces with their own settings
- The database is a single sqlite3 database file
- SMA (Moving Average)
- ESMA (Exponential Moving Average)
- MACD
- Momentum
- RSI (Relative Strength Index)
- Stochastics
- ATR (Average True Range)
- Bollinger
- Standard Deviation
- Price List Report
- Price Change Report
- Portfolio Performance Report
- Portfolio Value Report
Download (2.3MB)
Added: 2006-05-04 License: QPL (QT Public License) Price:
1274 downloads
SplitLink 2.0.7
Split Link is a Firefox extension that will allow you to view the true URL that you are being redirected to. more>>
Split Link is a Firefox extension that will allow you to view the true URL that you are being redirected to. Sometimes links may contain hexadecimal characters or numerous parameters that make them more difficult to read. By using Split Link you can remove the parameters, remove javascript code from links, and convert all of the hexadecimal characters back to ASCII.
After Split Link is installed it will appear on the right click menu. Just right click on a link and then click "Split Link". A new window will pop up containing the reformatted URLs. If you click on one of the URLs in the new window, it will automatically redirect the parent window to that URL.
<<lessAfter Split Link is installed it will appear on the right click menu. Just right click on a link and then click "Split Link". A new window will pop up containing the reformatted URLs. If you click on one of the URLs in the new window, it will automatically redirect the parent window to that URL.
Download (0.074MB)
Added: 2007-07-28 License: MPL (Mozilla Public License) Price:
928 downloads
Math::Logic 1.19
Math::Logic is a Perl module that provides pure 2, 3 or multi-value logic. more>>
Math::Logic is a Perl module that provides pure 2, 3 or multi-value logic.
SYNOPSIS
use Math::Logic qw( $TRUE $FALSE $UNDEF $STR_TRUE $STR_FALSE $STR_UNDEF ) ;
# 1 0 -1 TRUE FALSE UNDEF
use Math::Logic :NUM ; # $TRUE $FALSE $UNDEF -- what you normally want
use Math::Logic :ALL ; # All the constants
use Math::Logic :STR ; # $STR_TRUE $STR_FALSE $STR_UNDEF
# 2-degree logic
my $true = Math::Logic->new( -value => $TRUE, -degree => 2 ) ;
my $false = Math::Logic->new( -value => $FALSE, -degree => 2 ) ;
my $x = Math::Logic->new_from_string( TRUE,2 ) ;
print "true" if $true ;
# 3-degree logic (non-propagating)
my $true = Math::Logic->new( -value => $TRUE, -degree => 3 ) ;
my $false = Math::Logic->new( -value => $FALSE, -degree => 3 ) ;
my $undef = Math::Logic->new( -value => $UNDEF, -degree => 3 ) ;
my $x = Math::Logic->new_from_string( FALSE,3 ) ;
print "true" if ( $true | $undef ) == $TRUE ;
# 3-degree logic (propagating)
my $true = Math::Logic->new( -value => $TRUE, -degree => 3, -propagate => 1 ) ;
my $false = Math::Logic->new( -value => $FALSE, -degree => 3, -propagate => 1 ) ;
my $undef = Math::Logic->new( -value => $UNDEF, -degree => 3, -propagate => 1 ) ;
my $x = Math::Logic->new_from_string( ( UNDEF, 3, -propagate ) ) ;
print "undef" if ( $true | $undef ) == $UNDEF ;
# multi-degree logic
my $True = 100 ; # Define our own true
my $False = $FALSE ;
my $true = Math::Logic->new( -value => $True, -degree => $True ) ;
my $very = Math::Logic->new( -value => 67, -degree => $True ) ;
my $fairly = Math::Logic->new( -value => 33, -degree => $True ) ;
my $false = Math::Logic->new( -value => $False, -degree => $True ) ;
my $x = Math::Logic->new_from_string( "25,$True" ) ;
print "maybe" if ( $very | $fairly ) > 50 ;
# We can have arbitrarily complex expressions; the result is a Math::Logic
# object; all arguments must be Math::Logic objects or things which can be
# promoted into such and must all be compatible. The outcome depends on
# which kind of logic is being used.
my $xor = ( $x | $y ) & ( ! ( $x & $y ) ) ;
# This is identical to:
my $xor = $x ^ $y ;
Perls built-in logical operators, and, or, xor and not support 2-value logic. This means that they always produce a result which is either true or false. In fact perl sometimes returns 0 and sometimes returns undef for false depending on the operator and the order of the arguments. For "true" Perl generally returns the first value that evaluated to true which turns out to be extremely useful in practice. Given the choice Perls built-in logical operators are to be preferred -- but when you really want pure 2-degree logic or 3-degree logic or multi-degree logic they are available through this module.
The only 2-degree logic values are 1 (TRUE) and 0 (FALSE).
The only 3-degree logic values are 1 (TRUE), 0 (FALSE) and -1 (UNDEF). Note that UNDEF is -1 not undef!
The only multi-degree logic values are 0 (FALSE)..-degree -- the value of TRUE is equal to the degree, usually 100.
The -degree is the maximum value (except for 2 and 3-degree logic); i.e. logic of n-degree is n+1-value logic, e.g. 100-degree logic has 101 values, 0..100.
Although some useful constants may be exported, this is an object module and the results of logical comparisons are Math::Logic objects.
<<lessSYNOPSIS
use Math::Logic qw( $TRUE $FALSE $UNDEF $STR_TRUE $STR_FALSE $STR_UNDEF ) ;
# 1 0 -1 TRUE FALSE UNDEF
use Math::Logic :NUM ; # $TRUE $FALSE $UNDEF -- what you normally want
use Math::Logic :ALL ; # All the constants
use Math::Logic :STR ; # $STR_TRUE $STR_FALSE $STR_UNDEF
# 2-degree logic
my $true = Math::Logic->new( -value => $TRUE, -degree => 2 ) ;
my $false = Math::Logic->new( -value => $FALSE, -degree => 2 ) ;
my $x = Math::Logic->new_from_string( TRUE,2 ) ;
print "true" if $true ;
# 3-degree logic (non-propagating)
my $true = Math::Logic->new( -value => $TRUE, -degree => 3 ) ;
my $false = Math::Logic->new( -value => $FALSE, -degree => 3 ) ;
my $undef = Math::Logic->new( -value => $UNDEF, -degree => 3 ) ;
my $x = Math::Logic->new_from_string( FALSE,3 ) ;
print "true" if ( $true | $undef ) == $TRUE ;
# 3-degree logic (propagating)
my $true = Math::Logic->new( -value => $TRUE, -degree => 3, -propagate => 1 ) ;
my $false = Math::Logic->new( -value => $FALSE, -degree => 3, -propagate => 1 ) ;
my $undef = Math::Logic->new( -value => $UNDEF, -degree => 3, -propagate => 1 ) ;
my $x = Math::Logic->new_from_string( ( UNDEF, 3, -propagate ) ) ;
print "undef" if ( $true | $undef ) == $UNDEF ;
# multi-degree logic
my $True = 100 ; # Define our own true
my $False = $FALSE ;
my $true = Math::Logic->new( -value => $True, -degree => $True ) ;
my $very = Math::Logic->new( -value => 67, -degree => $True ) ;
my $fairly = Math::Logic->new( -value => 33, -degree => $True ) ;
my $false = Math::Logic->new( -value => $False, -degree => $True ) ;
my $x = Math::Logic->new_from_string( "25,$True" ) ;
print "maybe" if ( $very | $fairly ) > 50 ;
# We can have arbitrarily complex expressions; the result is a Math::Logic
# object; all arguments must be Math::Logic objects or things which can be
# promoted into such and must all be compatible. The outcome depends on
# which kind of logic is being used.
my $xor = ( $x | $y ) & ( ! ( $x & $y ) ) ;
# This is identical to:
my $xor = $x ^ $y ;
Perls built-in logical operators, and, or, xor and not support 2-value logic. This means that they always produce a result which is either true or false. In fact perl sometimes returns 0 and sometimes returns undef for false depending on the operator and the order of the arguments. For "true" Perl generally returns the first value that evaluated to true which turns out to be extremely useful in practice. Given the choice Perls built-in logical operators are to be preferred -- but when you really want pure 2-degree logic or 3-degree logic or multi-degree logic they are available through this module.
The only 2-degree logic values are 1 (TRUE) and 0 (FALSE).
The only 3-degree logic values are 1 (TRUE), 0 (FALSE) and -1 (UNDEF). Note that UNDEF is -1 not undef!
The only multi-degree logic values are 0 (FALSE)..-degree -- the value of TRUE is equal to the degree, usually 100.
The -degree is the maximum value (except for 2 and 3-degree logic); i.e. logic of n-degree is n+1-value logic, e.g. 100-degree logic has 101 values, 0..100.
Although some useful constants may be exported, this is an object module and the results of logical comparisons are Math::Logic objects.
Download (0.012MB)
Added: 2007-07-02 License: Perl Artistic License Price:
847 downloads
Secleted [ 0 ] software to compare
Copyright Notice:
Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future software development. The above true religion search only lists software in full, demo and trial versions for free download. Download links are directly from our mirror sites or publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed