Looking at the original code from that page, I conclude that it is the body of a subroutine, and not a standalone program.

So, wrap it in a subroutine (say, calculate_protein_details and call that subroutine with 2 arguments: a protein sequence $protein (the input), and an empty hash %results (the output, which whill be filled in by the subroutine).

#!/usr/bin/perl use strict; use warnings; main(); exit; sub main { # I took this example sequence from uniprot.org # from entry >sp|P02754|LACB_BOVIN Beta-lactoglobulin my $protein = "MKCLLLALALTCGAQALIVTQTMKGLDIQKVAGTWYSLAMAASDISLLDAQSA +PLRVYVEELKPTPEGDLEILLQKWENGECAQKKIIAEKTKIPAVFKIDALNENKVLVLDTDYKKYLLFC +MENSAEPEQSLACQCLVRTPEVDDEALEKFDKALKALPMHIRLSFNPTQLEEQCHI"; my %results = (); calculate_protein_details( $protein, \%results); while (my ($k,$v) = each %results) { print $k, " => ", $v, "\n"; } } sub calculate_protein_details { my ($protein, $hash_ref) = @_; # copy here the code (except the first line) from # http://www-nmr.cabm.rutgers.edu/bioinformatics/ZebaView/help.html # (not your mangled code...) }

Output:

extinction => 16960 pI => 4.93 MW_N15 => 20105.52 MW => 19883.00 MW_SeMet => 20117.50 MW_N15_C13 => 20986.05

( Don't complicate matters and solve one problem at a time. Reading a fasta file to get its sequence is a entirely separate thing )

UPDATED: restructured the code a bit


In reply to Re: Iso electric point calculation using perl by erix
in thread Iso electric point calculation using perl by yuvraj_ghaly

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.