#!/usr/bin/perl -w use strict; use Data::Dumper; #open file for reading open(IN,"/Users/me/Desktop/CCDS.current.txt") or die " Can't open file: $!"; #open out file for writing open(OUT, ">/Users/me/Desktop/withdrawndata.txt"); #remove the header my $firstline= ; chomp $firstline; while(){ chomp; # remove the newline character my @fields = split/\t/; # split the file into columns where eachline in it #populates and array for that column. if($fields[5] =~ m/Withdrawn/){ # print eachline that has "Withdrawn" in field[5] print OUT "$_\n"; # print to file } } close(IN); close(OUT); __DATA__ #chromosome nc_accession gene gene_id ccds_id ccds_status cds_strand cds_from cds_to 1 NC_000001.8 NCRNA00115 79854 CCDS1.1 Withdrawn - 801942 802433 1 NC_000001.10 SAMD11 148398 CCDS2.2 Public + 861321 879532 1 NC_000001.10 NOC2L 26155 CCDS3.1 Public - 880073 894619 1 NC_000001.10 PLEKHN1 84069 CCDS4.1 Public + 901911 909954 1 NC_000001.10 HES4 57801 CCDS5.1 Public - 934438 935352 1 NC_000001.10 ISG15 9636 CCDS6.1 Public + 948953 949857 1 NC_000001.10 C1orf159 54991 CCDS7.2 Public - 1018272 1026922 1 NC_000001.10 TTLL10 254173 CCDS8.1 Public + 1115433 1120521 1 NC_000001.10 TNFRSF18 8784 CCDS9.1 Public - 1138970 1141950 1 NC_000001.10 TNFRSF18 8784 CCDS10.1 Public - 1139223 1141950 1 NC_000001.10 TNFRSF4 7293 CCDS11.1 Public - 1146934 1149506