Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: please help me!! by tachyon
in thread please help me parse genbank DNA file by foxy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found