open(FH, 'cut -d" " -c6 file|') or die $!; # or open(FH, "awk '{print \$6}' file|") ... while() { ... } close FH or die $!; # Check close on pipe opens # Also, you might try a regex which # uses qr and only saves what you want my $re = qr/(?:\S+\s+){5}(\S+)/; ... while () { next unless $_ =~ $re; my $field = $1; ... }