Not sure if this list supports basic questions, but I'll pose the query to find out.
I am new to PERL and working on an basic PERL script. The script will import values into an array. when complete, I want to do a calculation based on two feilds and drop the answer into the third field. Basically I have the following script, but keep getting a syntax error and can't figure out where I've gone wrong:
sub {
$output = '';
chomp $_[0];
$delim = $_[1];
@input_fields = split /$delim/, $_[0];
# input the values into the array
for($i=0; $i<$#input_fields; $i++) {
if i$ == 2
{
# perform the calculation
$input_fields[$i] = $input_fields[$i-1] * $input_fields[$i-2];
}
output = $output . $input_fields[$i] . $delim;
}
$output = $output . $input_fields[$#input_fields] . "\n";
return($output);
}
Any help is grealy appreciated!
Barney
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
