#!/usr/bin/perl use strict; use warnings; use FileHandle; use Data::Dumper qw/Dumper/; my $file = 'test.txt'; my $fh = FileHandle->new(); my @ids = (); if( $fh->open($file, "<") ) { while( my $line = $fh->getline() ) { my ($id) = $line =~ m/^((?:[^\t]+\t){3}[^\t]+)/; push @ids, $id; } $fh->close(); }else{ die("Error reading file $file: $!"); } print Dumper \@ids;