#!/usr/bin/perl -w use strict; my @x; # your x values my @y; # your y values open FH, 'your file'; # whatever your data file is while (my $line = ){ my @z = split ' ', $line; # split on space to get # your values in an array push(@x ,unshift @z); # take first element of z and # add it to x push(@y,$_) foreach(@z); # add the rest to y } close FH;