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#!/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
In reply to Redone DB split help needed by Brokensoulkeeper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |