Forum     

Go Back   Digit Technology Discussion Forum > Software > Open Source
Register FAQ Calendar Mark Forums Read

Open Source A place where you can talk to like-minded people about the fastest growing software movement today! Discuss anything and everything about Open Source software and Operating Systems.


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 26-10-2005, 12:28 AM   #1 (permalink)
Broken In
 
Join Date: Nov 2003
Location: Pune
Posts: 195
Default weird perl


i wrote this code to find the nCr of a no. in perl 5 in windows.

i have used subroutines. but since i used it for first time(specified in college assignemnt ) i im very good with it. any way, the program ran properly in windows.

now when i typed the code in our college ( clients on windows 98 connect to server on redhat 8 thru puttry telnet tool-perl there too is version 5.xx)
it simply didnt budge. someone said subroutine isnt returning value. so made necesarry changes and sat for 3 hrs but program just didnt run.

when i run the same program(whihc wrote at home in windows perl) in mandrake 10.1 at home, it runs and no errors too. SO WHY DIDNT IT RUN IN RED HAT 8 IN COLLEGE.

Quote:
SAVE THIS CODE in notepad as ncr.pl and in console(dos or linux)

note: give values in command line while running
ex:
type at prompt ($) perl ncr.pl 12 8

to find 12C8

remove the first line if running in windows

Code:
#! /usr/bin/perl
system "clear";

print "\nProgram Name=> nCr \n";

$n=$ARGV[0];

$r=$ARGV[1];
chomp $n;
chomp $r;

if($n<$r || $n<0 || $r<0)
{
print "\n U MORON, n cannot be < r or -ve. Enter again\n";
}

else
{
print "\n n=         $n\n";
print "\n r=         $r\n";

$nfact=1;

$rfact=1;

$nrfact=1;


&fact($n,$r);

print "\n n!=        $nfact\n";

print "\n r!=        $rfact\n";

print "\n (n-r)!=    $nrfact\n";

$l=$rfact*$nrfact;

print "\n r!*(n-r)!= $l\n";

$m=$nfact/$l;

print "\n Formula for nCr=n!/(r!*(n-r)!) \n";
print "\n nCr=$n!/($r!*($n-$r)!)=$m \n";
}



sub fact
{

for($i=1;$i<=$n;$i++)

{

$nfact*=$i;

}



for($j=1;$j<=$r;$j++)

{

$rfact*=$j;

}



for($k=1;$k<=($n-$r);$k++)

{

$nrfact*=$k;

}

}
PLZ HELP ME
__________________
HP DV 9222tx laptop

core2duo 1.66 @533
512 x2 =1gb ram @533
80x2=160gb hdd
17" widescreen.
nvidia geforce 7600go 256mb
vantec lapcool 3
hauppage usb TV stick with remote
GunshotSilence is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 26-10-2005, 02:19 AM   #2 (permalink)
Wise Old Owl
 
desertwind's Avatar
 
Join Date: Nov 2004
Location: Hyderabad
Posts: 1,096
Default

It is working fine on my FC4 box.


so what is the error u getting on RH8, and please post the perl version on RH8
__________________
Sometime you'll think you understand everything

...Then you'll regain consciousness
desertwind is offline  
Old 26-10-2005, 10:23 PM   #3 (permalink)
Broken In
 
Join Date: Nov 2003
Location: Pune
Posts: 195
Default

well after running on RH8 it showed

n=12
r=8

thats it

nothing else.

but same program on mandrake is running fine.
__________________
HP DV 9222tx laptop

core2duo 1.66 @533
512 x2 =1gb ram @533
80x2=160gb hdd
17" widescreen.
nvidia geforce 7600go 256mb
vantec lapcool 3
hauppage usb TV stick with remote
GunshotSilence is offline  
Old 28-10-2005, 11:09 PM   #4 (permalink)
Wise Old Owl
 
desertwind's Avatar
 
Join Date: Nov 2004
Location: Hyderabad
Posts: 1,096
Default

Sometimes different versions may create problems. I really had a hard time compiling audioscrobbler plugin for rhythmbox in FC4 which uses python 2.4. but it worked fine when compiled using python 2.3. Thats why i asked for the perl compiler version on RH8. RH8 is pretty old. so u may having a old compiler. try upgrading the compiler.
__________________
Sometime you'll think you understand everything

...Then you'll regain consciousness
desertwind is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 02:50 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2