1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
sub Read { my $readseq = ''; my $readname = ''; tie my @lines, 'Tie::File','C:\Users\Blub\Read\reads.fasta' ; if( defined $lines[$rls] ) { # false und das stimmt nicht!! $readname = $lines[$rls-1]; $readname = substr( $readname, 0, 10 ); $readname =~ s/\D//g; $readseq = $lines[$rls]; $rls += 2; } else { $switch = 'false'; $readname = 'false'; } untie @lines; return( $readname, $readseq ); }
Guest BlackSheepEinen wunderschönen!
Ich hab unter Windows 7 64 mit Tie::File folgendes Problem. Die If-Abfrage ob das Element im Array definiert ist liefert "false" obwohl ein Element vorhanden ist.
https://metacpan.org/module/Tie%3A%3AFile#recseprecsep
What is a 'record'? By default, the meaning is the same as for the <...> operator: It's a string terminated by $/, which is probably "\n". (Minor exception: on DOS and Win32 systems, a 'record' is a string terminated by "\r\n".) You may change the definition of "record" by supplying the recsep option in the tie call:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
sub Read { # parameter übernehmen my $rls=shift(); my $readseq = ''; my $readname = ''; my $file='C:\Users\Blub\Read\reads.fasta'; if( tie(my @lines, 'Tie::File',$file) ){ if( defined $lines[$rls] ) { $readname = $lines[$rls-1]; $readname = substr( $readname, 0, 10 ); $readname =~ s/\D//g; $readseq = $lines[$rls]; $rls += 2; } else{ if( $#lines < $rls ){ warn("Line $rls don't exists! There are only ".@lines." Lines!\n"); } else{ warn("Line $rls is not defined!\n"); } $switch = 'false'; $readname = 'false'; } untie @lines; } else{ warn("Can't tie File $file ($!)\n"); } return( $readname, $readseq ); }
local $/="\x0A";