CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: General Discussions: General Questions:
need help in running perl module

 



astrosanthosh
New User

Jul 8, 2013, 10:37 PM

Post #1 of 6 (2344 views)
need help in running perl module Can't Post

Namaste,
i have installed perl module date::Indian on my server (247zilla cloud server) but when i tried to run example.pl its giving this error
"Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@onlinejyotish.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

please help me to run this script on my server.


Zhris
User

Jul 11, 2013, 5:54 AM

Post #2 of 6 (2325 views)
Re: [astrosanthosh] need help in running perl module [In reply to] Can't Post

Hi,

There could be numerous reasons why you have encountered an error 500. Could you please provide your stripped down / tested code snippet. Alternatively try adding the following ( Carp to display errors to screen, valid content type ).


Code
use CGI::Carp qw( fatalsToBrowser ); 
print "content-type: text/plain\n\n";


Chris


astrosanthosh
New User

Jul 13, 2013, 10:46 PM

Post #3 of 6 (2301 views)
Re: [Zhris] need help in running perl module [In reply to] Can't Post

Dear sir, thanks for your reply. here is the code which i am talking about. i have installed date::indian perl module on my server (my site hosting on 247zilla.com). they are given these details on server related to perl module: "Location of Your Perl Module(s)

Path: /home/onlinejy/perl
Using Your Perl Module(s)

You will need to add /home/onlinejy/perl to the include path.
You can do this by adding the following code to your script:


BEGIN {
my $base_module_dir = (-d '/home/onlinejy/perl' ? '/home/onlinejy/perl' : ( getpwuid($>) )[7] . '/perl/');
unshift @INC, map { $base_module_dir . $_ } @INC;
}"
please do help. Thanks


Code
#!/usr/bin/perl 

package ::Indian;
use Indian;
use strict;
use warnings;
use DateTime;
use CGI::Carp qw( fatalsToBrowser );
print "content-type: text/plain\n\n";

# Names.
my $tithiid = [ qw(
su.padyami su.vidiya su.tadiya su.chaviti su.panchami
su.shasthi su.saptami su.astami su.navami su.dasami
su.ekadasi su.dwadasi su.triodasi su.chaturdasi pournami
kr.padyami kr.vidiya kr.tadiya kr.chaviti kr.panchami
kr.shasthi kr.saptami kr.astami kr.navami kr.dasami
kr.ekadasi kr.dwadasi kr.triodasi kr.chaturdasi amavasya
) ];

my $nkid = [ qw(
Aswini Bharani Krittika Rohini Mrigasira Aridra
Punarvasu Pushya Aslesha Makha Pubba Uttara
Hasta Chitta Swati Visakha Anuradha Jyeshta
Moola Poorvashadha Uttarashadha Sravana Dhanishta
Satabhisha Poorvabhadra Uttarabhadra Revati
) ];

my $yogaid = [ qw(
Vishkambha Prithi Ayushman Saubhagya Sobhana Atiganda
Sukarman Dhrithi Soola Ganda Vridhi Dhruva
Vyaghata Harshana Vajra Siddhi Vyatipata Variyan
Parigha Siva Siddha Sadhya Subha Sukla
Bramha Indra Vaidhruthi
)];

my $karanaid = [ qw(
Bava Balava Kaulava Taitula Garija Vanija
Visti Sakuna Chatuspada Naga Kimstughna
)];

# Hyderabad 78.30E 17.20N tz = 5.5;
# Raleigh 78:39W 35:46N tz = -4.0;
# Rajahmundry 81:48E 17:00N 17:02
my $dt = DateTime->now;
my $d1 = $dt->ymd;
my $ymd = $d1;
my $tz = "5.5";
my $locn = "79.6E" . ' '. "18.56N" ;
print " args: $ymd, $tz, $locn \n";
my $d = Date::Indian-> new( ymd=> $ymd,
tz => $tz,
locn => $locn,
);
my ($sr, $ss, $fl) = $d->sunriseset();
print "Sun rise: ",hms($sr),"\n";
print "Sun transit: ",hms(($sr+$ss)/2), "\n";
print "Sun set : ",hms($ss),"\n";

my ($mr, $ms, $fl) = $d->moonriseset();
print "Moon rise: ",hms($mr),"\n" if $mr;
print "Moon set : ",hms($ms),"\n" if $ms;


my %th = $d->tithi_endings();
for my $t (sort keys %th){
print "Tithi ", $tithiid->[$t], " ends at ", hms($th{$t}), "\n";
}

my %nk = $d->nakshyatra_endings();
for my $t (sort keys %nk){
print "Nakshyatra ", $nkid->[$t] , " ends at ", hms($nk{$t}), "\n"
if $nk{$t} > 0 && $nk{$t} <= 24.0;
}

#my $sun = $d -> sun()-> n_long();
#print "Sun's longitude = $sun\n";

# Return hh:mm form string for the number.
sub hms{
my $arg = shift;
my $sign = '';
$sign = '-' if $arg < 0;
$arg *= -1 if $arg < 0;
my $h = int($arg);
my $m = int(($arg - $h)*60.0);
my $s = int($arg*3600.0)%60;
$m += 1 if $s >= 30;
if ($m == 60){
$m = 0;
$h += 1;
}
$h = '0'.$h if $h < 10;
$m = '0'.$m if $m < 10;
return $sign.$h . ':' . $m;
}

# Sun chara tracking.

my ($nav, $t ) = $d->sunchara();
if ($nav){
if ( $nav % 9 != 0 ){ # Change of start & navamsa case.
print "Sun's in ", $nkid->[int($nav/4)], " ", $nav % 4, " at: ",hms($t),"\n";
}else{# Change of sign case.
print "Solar ingress to ", int($nav/9)," at: ",hms($t), "\n";
}
}
print "Length of the day: ", hms($d->daylength()), "\n";

# New moon calculations:

my $td = Date::Indian -> new ( jdate => $d->newmoon(), tz => '5:30');
my ($yr,$mn,$dt,$tm) = $td->ymd();
print "Prev new Moon: $yr-$mn-$dt ", hms($tm), "\n";

$td = Date::Indian -> new ( jdate => $d->newmoon(1), tz => '5:30');
($yr,$mn,$dt,$tm) = $td->ymd();
print "Next new Moon: $yr-$mn-$dt ", hms($tm), "\n";

# Rahu, Gulika and Yamaganda kalam.
my ($from, $to) = $d->rahu_kalam();
print "Rahu kalam ", hms($from), " to ", hms($to), "\n";
($from, $to) = $d->gulika_kalam();
print "Gulika kalam ", hms($from), " to ", hms($to), "\n";
($from, $to) = $d->yamaganda_kalam();
print "Yamaganda kalam ", hms($from), " to ", hms($to), "\n";

# Durmuhurtas.
my ($d1_s, $d1_e, $d2_s, $d2_e) = $d->durmuhurtam();
print "Durmurtam ", hms($d1_s), " to ", hms($d1_e), "\n";
print "Durmurtam ", hms($d2_s), " to ", hms($d2_e), "\n"
if $d2_s;


#Varjyam.
my @out = $d->varjyam();
foreach my $vs ( @out){
print "varjyam from ", hms($vs)," till ", hms($vs+1.6),"\n";
}

# Karanam:
my %th = $d->karana_endings();
for my $t (sort keys %th){
my $k;
$k = 10 if $t == 0;
$k = $t - 50 if $t >= 57;
$k = ($t-1) % 7 if ($t >0) & ($t <57);
print "Karana ", $karanaid->[$k], " ends at ", hms($th{$t}), "\n";
}

# Compute traditional saka date for the gregorian calendar date.
# Takes care of inter calary months.
sub greg2saka{
my $self = shift;
my $sun = $self->sun();
my ($sr, $ss, $flag) = $self -> sunriseset();
my $day = int($self->tithi($sr/24.0)) % 30;
my $td = Date::Indian -> new ( jdate => $self->newmoon(), tz => '5:30');
my ($yr,$mn,$dt,$tm) = $td->ymd();
$sun = $td ->sun();
my $sl = $sun->n_long();
my $m = int($sl/30);
my $year = $yr - 78;
$year -= 1 if int($sl/30) < 11;
my $mon = int($sl/30 + 1) % 12;
$td = Date::Indian -> new ( jdate => $self->newmoon(1), tz => '5:30');
($yr,$mn,$dt,$tm) = $td->ymd();
$sun = $td ->sun();
$sl = $sun->n_long();
$mon = $mon + 0.1 if $mon == int($sl/30 + 1) % 12;
print "year = $year, month = $mon, day = $day\n";
}
greg2saka( $d );


In Reply To


FishMonger
Veteran / Moderator

Jul 14, 2013, 8:11 AM

Post #4 of 6 (2294 views)
Re: [astrosanthosh] need help in running perl module [In reply to] Can't Post

If the fatalsToBrowser line didn't help, then the problem is prior to that statement. I suspect that it's the first use statement.

D:\test>astrosanthosh.pl

Quote
Can't locate Indian.pm in @INC (@INC contains: D:/strawberry/perl/site/lib/MSWin32-x64-multi-thread D:/strawberry/perl/site/lib D:/strawberry/perl/vendor/lib D:/strawberry/perl/lib .) at D:\test\astrosanthosh.pl line 4.
BEGIN failed--compilation aborted at D:\test\astrosanthosh.pl line 4.

If you move the CGI::Carp line up (prior to the package statement), you will get that full error message in the browser.

Why do you have these 2 statements?

Code
package ::Indian; 
use Indian;



(This post was edited by FishMonger on Jul 14, 2013, 8:11 AM)


astrosanthosh
New User

Jul 14, 2013, 8:37 AM

Post #5 of 6 (2290 views)
Re: [FishMonger] need help in running perl module [In reply to] Can't Post

Thanks for your reply. I am getting this error

Code
Software error: 

Can't locate Indian.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.8/x86_64-linux /usr/local/lib/perl5/5.8.8 /usr/local/lib/perl5/site_perl/5.8.8/x86_64-linux /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl .) at pan.pl line 5.
BEGIN failed--compilation aborted at pan.pl line 5.

please help me in giving right path. thanks


astrosanthosh
New User

Jul 14, 2013, 8:41 AM

Post #6 of 6 (2289 views)
Re: [FishMonger] need help in running perl module [In reply to] Can't Post

Thanks I used this code and its now working.

Code
use lib '.';  
use lib "$ENV{DOCUMENT_ROOT}/cgi-bin";

thanks for your help

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives