#!/usr/bin/perl -w use strict; my $input = "a b c d e f g"; my @words = split(/\s+/,$input); print @words[2,3], "\n"; __END__ Prints: cd