my %filehash = (); while (<>){ @pline = split (/\!/,$_); my $keycolumn = $pline[15]; # based on this col values split files unless ($filehash{$keycolumn}){ $filehash{$keycolumn}{name} = $pline[15]; open $filehash{$keycolumn}{handle},">$filehash{$keycolumn}{name}; # open distinct file handles for each distinct value found in col 15 } print {$filehash{$keycolumn}{handle}} @pline; } # In the above code iam considering all col's , but my new requirement is , for some rows i should only some predifined col's which can 1,3,5,6,7 i.e. i need slice these indices from @pline before writing it into corresponding file