diyaz has asked for the wisdom of the Perl Monks concerning the following question:
I hope this will be a good example to learn threading from. Thanks!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 = <INFILE>; #grabbing header chomp $header; my @headerArray = split("\t", $header); my $sizeheader=@headerArray; for my $line (<INFILE>) { 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;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to split file for threading?
by BrowserUk (Patriarch) on Jun 23, 2015 at 14:16 UTC | |
by diyaz (Beadle) on Jun 23, 2015 at 14:46 UTC | |
by BrowserUk (Patriarch) on Jun 23, 2015 at 15:15 UTC | |
by diyaz (Beadle) on Jun 23, 2015 at 16:48 UTC | |
by BrowserUk (Patriarch) on Jun 23, 2015 at 19:14 UTC | |
| |
by marioroy (Prior) on Jun 26, 2015 at 17:22 UTC | |
by stevieb (Canon) on Jun 23, 2015 at 14:53 UTC | |
by afoken (Chancellor) on Jun 23, 2015 at 16:40 UTC | |
by diyaz (Beadle) on Jun 23, 2015 at 15:52 UTC | |
Re: How to split file for threading?
by Anonymous Monk on Jun 23, 2015 at 14:19 UTC | |
by diyaz (Beadle) on Jun 23, 2015 at 14:47 UTC | |
by stevieb (Canon) on Jun 23, 2015 at 15:01 UTC | |
by diyaz (Beadle) on Jun 23, 2015 at 15:47 UTC | |
by BrowserUk (Patriarch) on Jun 23, 2015 at 16:01 UTC | |
| |
Re: How to split file for threading?
by wollmers (Scribe) on Jun 23, 2015 at 15:02 UTC | |
Re: How to split file for threading?
by marioroy (Prior) on Jun 26, 2015 at 20:04 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |