#!/usr/bin/perl -w $xf = "~/OUTPUT"; #enter file name location here <- $num = 1000; #enter number of iterations here <- $tnum = 20; #enter number of pdbs necessary <- $lab = "BRO"; #enter label for output <- open (XF, $xf) or die "no $xf exists!!"; while (my $line = <XF>) { #reads file, takes out erroneous data if($line = m/TIMESTEP/) { #saves each chunk of 2703 line to $line = ""; #one array slot in superchunk @file = scalar(@trans); @superchunk = $trans[0]; } #trans has only one #slot in it i want that #slot to go to one slot in super chunk else if($line = m/ATOM/) { @file = $line; } $num / $tnum = $div; } for($i=1;$i<=$tnum;++$i) { @name = ('> ', $lab , '_' , $i , '.pdb'); @name = scalar(@hopname); print "$hopname[0] \n"; open (OU, $hopname[0]) or die "File would not open!!"); #The $lab and $i vars need to be output into t +he filename #string so that each filename is different yet + identify- #-able as part of this process and the .pdb is + the file #extention print OU (@superchunk[$i*$div]); close OU } #prints every 20th 2703 line chunk +to #file, different file for each +chunk close XF
I am completely new to this language and have very little if any ability to use it. This here is my best attempt to create a program that splits up a very large output file from a program called DL_POLY the idea as notes should imply in code is to read out lines of the big output file and then every time that the word TIMESTEP is used to take what is has read and put it in to a scalar and the transfer the scalar to a single slot of an array. the scalar to my knowledge should retain the "\n" so that when it is later written to a file the format should look the same as it did in the oupt put file. once it has read through the entire file and created the @superchunk which contains a single entry for every block which was split off it then goes through @superchunk and at 20 seperate locations it picks out an entry and writes it to a file that is named by a label and a number. the label should remain static and the number should vary through out the process. the .pdb is text that needs to be tact on to the file name so that the file wil run through the immageing program that will be used. so after the script is run on the UNIx supercomputer , cause thats where the files at. i should end up with 20 files called BRO_#.pdb am i right ???? will this code work or am i implementing things out of order or in the wrong fashion. be blunt i know i am not doing this very well thats why i am here i figured i could learn from some pros :) thanx again

In reply to Redone DB split help needed by Brokensoulkeeper

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.