#!/usr/local/bin/perl -w use strict; print "Please type in the name of a file\n"; my $file = ; chomp $file; my ($annotation, $seq) = get_dna ($file); # convert $annotation array reference to a real array my @annotation = @$annotation; print "Annotation:\n\n", @annotation, "\n\n\n"; print "Sequence:\n\n", $seq, "\n"; sub get_dna { my ($file) = @_; my @annotation = (); my $seq = ''; my $in_sequence = 0; open FILE, $file or die "Can't open $file, Perl says $!\n"; while ( my $line = ) { last if $line =~ m|^//\n|; # stop if line has just // on it $in_sequence = 1 if $line =~ m/^ORIGIN/; if ($in_sequence) { $seq .= $line; } else { push @annotation, $line; } } close FILE; # remove all spaces and digits from $seq. add \n to remove newlines $seq =~ s/[\s0-9]//g; # return @annotation array as a scalar reference and scalar $seq return \@annotation, $seq; }