Thanks Again. Works like I want it too! Seek was good idea. You're pretty brainy. Here's what I ended up using.
#!/usr/bin/perl5.8.8 use strict; use warnings; #use autodie; dies if open/close...fail print "Enter file to process\t"; my $count = <>; #captures input from STNDIN and finds the file associa +ted with that number chomp $count; tempProteinFamFileCreator(); #creates a temp file with protein family sub tempProteinFamFileCreator { my $infile = $count."_ProFam"; #iterates through all the protein famil +y files with the count variable open (my $INFILE,"<", $infile); my $flag = 0; open (my $TEMPfa,">",'temp'); while(<$INFILE>) { if ($_ =~/^##UniRef90_([\w\d]+) Protein Family/) { close ($TEMPfa); open ($TEMPfa,">",'temp'); seek $TEMPfa, 0 ,0; } if ($_ =~/^>UniRef90_[\w\d]+\.UniRef100_[\w\d]+/ || $_ =~/^[\w +\d]+/) { chomp $_; print $TEMPfa "$_\n"; } if ($_ =~/^>File/) { close ($TEMPfa); } } #end of while loop close ($INFILE); #closes the $INFILE handle } #end of subroutine tempProteinFamFileCreator
In reply to Re^4: Overwriting temp file
by Jeri
in thread Overwriting temp file
by Jeri
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |