in reply to How to awk a grep result in-script

How do I perform the equivalent of "awk {'print $1,$2,$8'}" in perl?

Here is the answer to this particular question, although see haukex's reply (++) for some better approaches regarding the wider topic of shelling out.

#!/usr/bin/env perl use strict; use warnings; my $in = 'z y x w v u t s r q p'; my @chars = split (/ /, $in); print "@chars[0,1,7]\n";

Note that arrays in Perl by default start indexing from zero. Don't change this default unless you enjoy being hunted down by your co-developers.