0

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

for(my $i=2;$i<table->last_record;$i++)
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].

5
Contributors
10
Replies
11
Views
8 Years
Discussion Span
Last Post by weer
0
my @data1=(1,6,3,4,5);
for($i=1;$i<=$#a;$i++)
{
        $b=$a[$i]-$a[$i-1];
        print "Difference b/n current and previous records: $b\n";
}
0

sorry! actually i have assumed the '@a' in place of '@data1'.

my @data1=(1,6,3,4,5);
for($i=1;$i<=$#data1;$i++)
{
        $b=$data1[$i]-$data1[$i-1];
        print "Difference b/n current and previous records: $b\n";
}
0

Okay? So why are you attempting to do other's homework for them?

then what is the purpose of forums?

0

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.

0

i am also dame new in pearl field. thanks for this informative topic. i like it very much. keep posting here for more information.

0

i am new in this. so i have not any idea about this. so keep informing me here. thanks for this.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.