You probably want something like this but as you don't describe what this code is supposed to do (and it is somewhat incomprehensible) I am kinda guessing
#!/usr/local/bin/perl -w
use strict;
print "Please type in the name of a file\n";
my $file = <STDIN>;
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 = <FILE> ) {
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 newline
+s
$seq =~ s/[\s0-9]//g;
# return @annotation array as a scalar reference and scalar $seq
return \@annotation, $seq;
}
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|