use 5.010; use autodie; open my $fh, '<', 'text.txt'; while (<$fh>) { my @words = split /\s/; say "@words[0..1]" if @words >= 2; }