in reply to Pairing values from two arrays
Just a point that I didn't see made in any of the other responses, although broquaint's code doesn't have this problem:
returns the number of things in the array; but since arrays are 0 indexed, that means that on the last iteration of the loop
you're accessing undefined values in the two arrays you're attempting to coordinate. Perl may be complaining about that if you have warnings on, and if this processing takes place before you output the headers, you might be confuzling your web server. For that reason and others:
for( 0..scalar(@x_values) )
is a better way to write it ( $#ARRAY_NAME is the value of the last index of the array with name ARRAY_NAME ).
for( 0 .. $#x_values )
If not P, what? Q maybe?