print "Enter a directory´s path to work with all files in a folder or +a single file path\n\n"; chomp(my $input =<STDIN>); if ($input =~ /./){ ### attempt of recognizing a file extention $datei = $input; open(my $fastd,'<', $datei) or die "die datei $datei wurde nicht g +eöffnet: $!\n"; while (my $line = <$fastd>) { #reading fasta file chomp $line; if ($line =~ /^>/) { $header = $line; $header =~ s/>//g; } else { $sequences->{$header} .= $line } } }elsif($input =~ /[^.]/){ #### attempt of recognizing just a folder b +ut i know it wont work always $path = $input; opendir my $DIR, $path or die " the directory couldn't be opened\n +"; my @folder = grep -f "$path/$_", readdir $DIR; for my $file (@folder){ open (my $fastd ,'<', "$path/$file") or die "the file $file co +uldn't be opened: $!\n"; while (my $line = <$fastd>) { #reading fasta file chomp $line; if ($line =~ /^>/) { $header = $line; $header =~ s/>//g; } else { $sequences->{$header} .= $line } } } }
In reply to Re^2: working with directories
by madM
in thread working with directories
by madM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |