#!/usr/bin/perl # To redirect the output of your program to a file called hw1.out, # run it with the following command: # # -> ./hw1_1.pl > hw1_1.out # # You can then diff the results with my output with the following command: # # -> diff ~stacia/ws05/hw1_1.out hw1_1.out # # If this command returns nothing, the two files are identical. Note that # diff is sensitive to whitespace. $prefix = "/home/faculty/stacia/ws05/data/metazoa/"; opendir(METAZOA,"$prefix") || die "Couldn't open dir: $!"; @ALL_FILES = readdir(METAZOA); closedir(METAZOA); foreach $file (@ALL_FILES){ if($file =~ /.*\.gbk/) { open(I,$prefix . $file) || die "Couldn't open file: $!"; while() { if(/DEFINITION\s+(\S.*\S)\s+mitochon/) { print "$1, "; } if(/\/gene="COX1"/ && $last =~ /gene\s+(\S+)/) { print "$1"; } $last = $_; #save, in case the next line indicates that this is the COX-I gene } print "\n"; close(I); } }