use strict; use warnings; use Data::Dumper; #declarations my @rawfile; my $filter_count=0; #input open(INFILE, "<$ARGV[0]") || die "cannot open file:$!"; #### #filter file #------------------ # parse entire file my $header = ; #grabbing header chomp $header; my @headerArray = split("\t", $header); my $sizeheader=@headerArray; for my $line () { chomp $line; my @splitline = split("\t", $line); #my $poskey = $splitline[0] . ":" . $splitline[1]; for (@splitline){ if (/^$ARGV[1]/){ $filter_count++; push(@rawfile,$line); } } } close INFILE; print "Completed filtering $ARGV[0]\n"; print "Found $filter_count elements\n"; my $outfilename = substr($ARGV[0],0,length($ARGV[0])-4)."_filter.txt"; print "Filtering to output file: $outfilename\n"; #### #output file #------------------ open(OUTFILE, ">$outfilename") || die "cannot open file to write: $!"; print OUTFILE "$header\n"; for (@rawfile) { print OUTFILE "$_\n"; } close OUTFILE;