Perl DBF file doubt

Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2009
Posts: 1
Reputation: arun10427 is an unknown quantity at this point 
Solved Threads: 0
arun10427 arun10427 is offline Offline
Newbie Poster

Perl DBF file doubt

 
0
  #1
Oct 24th, 2009
Hi all,

I am a perl newbie. I am using a perl code to read a column full of data from 1 field into an array

  1. for(my $i=2;$i<table->last_record;$i++)
  2. my @data = $table->get_record($i,"Date");

Now for example if my @data[1] consists of list of numbers, I need to find the diff between current record and prev record till it reaches the end of array.. Perl has such complex way of array accessing, I donno how to do $data[$i]-$data[$i-1].
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven
 
0
  #2
Oct 26th, 2009
Have you actually tried doing exactly that?
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 8
Reputation: vbharathi is an unknown quantity at this point 
Solved Threads: 1
vbharathi vbharathi is offline Offline
Newbie Poster
 
0
  #3
Oct 26th, 2009
  1. my @data1=(1,6,3,4,5);
  2. for($i=1;$i<=$#a;$i++)
  3. {
  4. $b=$a[$i]-$a[$i-1];
  5. print "Difference b/n current and previous records: $b\n";
  6. }
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven
 
0
  #4
Oct 26th, 2009
Okay? So why are you using "$a[...]" when your array is @data1?
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 8
Reputation: vbharathi is an unknown quantity at this point 
Solved Threads: 1
vbharathi vbharathi is offline Offline
Newbie Poster
 
0
  #5
Oct 26th, 2009
sorry! actually i have assumed the '@a' in place of '@data1'.

  1. my @data1=(1,6,3,4,5);
  2. for($i=1;$i<=$#data1;$i++)
  3. {
  4. $b=$data1[$i]-$data1[$i-1];
  5. print "Difference b/n current and previous records: $b\n";
  6. }
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven
 
0
  #6
Oct 26th, 2009
Okay? So why are you attempting to do other's homework for them?
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 8
Reputation: vbharathi is an unknown quantity at this point 
Solved Threads: 1
vbharathi vbharathi is offline Offline
Newbie Poster
 
0
  #7
Oct 26th, 2009
Originally Posted by masijade View Post
Okay? So why are you attempting to do other's homework for them?
then what is the purpose of forums?
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven
 
0
  #8
Oct 26th, 2009
To help them learn. Definately not to do their homework for them.

Get them to attempt it, and post their code. Then, give them pointers on what they then need to do to fix that code, and get them to do it and post it again.

IOW, make them think. When you do it for them, they learn nothing.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 8
Reputation: vbharathi is an unknown quantity at this point 
Solved Threads: 1
vbharathi vbharathi is offline Offline
Newbie Poster
 
0
  #9
Oct 26th, 2009
ok...
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 3
Reputation: joles is an unknown quantity at this point 
Solved Threads: 0
joles joles is offline Offline
Newbie Poster
 
0
  #10
Oct 27th, 2009
i am also dame new in pearl field. thanks for this informative topic. i like it very much. keep posting here for more information.
Reply With Quote Quick reply to this message  
Reply

Tags
access, array

Message:




Views: 1367 | Replies: 10
Thread Tools Search this Thread



Tag cloud for access, array
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC