in reply to begginer help running perl script

By default, print goes to the STDOUT filehandle (your terminal). To direct your output to a file, open a file for output, and print to the new filehandle. UNTESTED:
$size = 5000; $overlap = 1; $overlap_size = 0.00*$size; $f = $ARGV[0]; local $/ = "\n>"; open $fh_out, '>', 'out.txt' or die "file out.txt: $!"; open(IN, "$f") || die "$f no\n"; while(<IN>){ s/>//g; $id = ''; $annt = ''; @ln = split /\n/; $defLine = shift @ln; $id = $1 if $defLine =~ /^(\S+)\s?/; $annt = $1 if $defLine =~ /^\S+\s+(.+)$/; $seq = join("",@ln); for(my $i=0; ($i*$size)<(length$seq); $i++){ $subSeq = substr($seq,$i*$size, $size); $subSeq =~ s/(\w{60)/\$1\n/g; chomp $subSeq; $start = $i*$size +1; $end = $start + (length$subSeq) - 1; print $fh_out ">$id:[",$start,'-',$end,"] $annt\n$subSeq\n"; if($overlap == 1 && ($i*$size+$overlap_size) < (length$seq)){ $subSeq = substr($seq,$i*$size+$overlap_size, $size); $subSeq =~ s/(\w{60)/\$1\n/g; chomp $subSeq; $start = $i*$size +1+$overlap_size; $end = $start + (length$subSeq) - 1; print $fh_out ">$id:[",$start,'-',$end,"] $annt\n$subSeq\n +"; } } } close $fh_out;

See also

Replies are listed 'Best First'.
Re^2: beginner help running perl script
by tstrobaugh (Initiate) on May 08, 2015 at 18:24 UTC

    Thanks for that, it does output to a text file now, but it has "doubles" of every output and it's all in one file, as opposed to every output of 5000 sequences being in a separate file. I don't think there is any need to rewrite the perl script though, he was using this script and generating the separate files. I just don't know the correct way to execute it with the proper switches or formatting to make that happen. I don't think this guy (before me) wrote scripts, just used available ones.