#!/usr/bin/perl -w use strict; my %data; open FILE , "home/you/your.file" or die "Cannot open: $!"; # extract data and store it in a hash of tables while( ) { @_=split; $data{$_[0]} = [ @_ ]; } close FILE; foreach( keys %data) { print join("\t" , @{$data{$_}}), "\n"; }