Hi, I am new to perl. I am trying to write a simple script that will pass through an array subtracting the value of the an element from that of the next and so on. Reporting each answer on a new line. One of my many problems is that I am not sure how to refer to the n+1 element in an array: Here what I have so far:
Any help would be much appreciated! Thanks, Art#!/usr/bin/perl use warnings; open(FILE, "filename.txt") or die("Unable to open file"); @List = <FILE>; close(FILE); foreach $line (@List) { print ($line+1) - $line); print "\n"; }
In reply to subtractionn in an array by brachysclereid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |