Hello, i am new to Perl and i m trying to write a code that will accept a pdb file, it will extract all the informations (atom number, atom type,residue name, residue number, x, y, z, b factor) and it will rearrange the residue number and it shoud save the new pdb in a new archive, i can't find a way to use a loop with a string array, this is the code:
print "\nEnter the input file: "; $inputFile = <STDIN>; chomp $inputFile; unless (open(INPUTFILE, $inputFile)) { print "Cannot read from '$inputFile'.\nProgram closing.\n"; <STDIN>; exit;} chomp(@dataArray = <INPUTFILE>); close(INPUTFILE); for ($line = 0; $line <= scalar @dataArray; $line++) { if ($dataArray[$line] =~ m/ATOM\s+(\d+)\s+(\w+)\s+(\w{3})\s+(\w)+\ +s+(\d+)\s+(\S+\.\S+)\s+(\S+\.\S+)\s+(\S+\.\S+)\s+(.+\S)(.\d\d+\.\d\d. ++)/ig) { $m1=$1; $m2=$2; $m3=$3; $m5=$5; $m6=$6; $m7=$7; $m8=$8; $m9=$9; $m10=$10; push(@m3,$m3); push(@m5,$m5); foreach $line (@m3,@m5) {if ($m3[$line] eq $m3[$line+1]) {$m5[$line]=$m5[$line+1];} elsif ($m3[$line] ne $m3[$line+1]){$m5[$line+1]=$m5[$line]+1;}} $~="PDBFORMAT"; format PDBFORMAT = ATOM @|||| @||| @|| @||| @|||||| @|||||| @|||||| @>>>>> @>>>>> $m1, $m2, $m3,$m5, $m6, $m7, $m8, $m9, $m10 . open(PDBFORMAT,">>my2pdb.txt") or die "Can't open anything"; write PDBFORMAT;}} close PDBFORMAT;

In reply to Rearrange the residue number of a pdb file according to the residues names by nastaziales

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.