in reply to Loading specific columns into arrays
G'day sidsinha,
"I have a string which contains data that can be split with "/\s+/" however, the data with which I want to plot the graph lies in column 3 and column 4."
Just ignore the values you don't want by assigning them to undef. Here's the technique (I'm assuming there's no Column 0):
$ perl -Mstrict -Mwarnings -le ' my $x = "a b c d"; my (undef, undef, $c, $d) = split /\s+/ => $x; print "$c $d"; ' c d
Update: That looks a tad clunky. Instead, you can take a slice of the split results: this might be better if you have more than four columns.
$ perl -Mstrict -Mwarnings -le ' my $x = "a b c d"; my ($c, $d) = (split /\s+/ => $x)[2,3]; print "$c $d"; ' c d
-- Ken
|
|---|