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].

Recommended Answers

All 10 Replies

Have you actually tried doing exactly that?

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";
}

Okay? So why are you using "$a[...]" when your array is @data1?

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";
}

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

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

then what is the purpose of forums?

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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.