root/branches/newmole/data/data.pl

Revision 13, 1.2 kB (checked in by gary, 3 years ago)

adjust file properties for ascii and perl files - no source change

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1#This program takes input  data files "*.dat" .
2#The output it generates is a series of references which is stored in
3#'finaldata.txt' .
4
5#!/usr/bin/perl
6
7#'tempdat.tmp' is an intermediate field
8$tdfile='tempdat.tmp';
9
10#finaldata.txt is the final formatted file
11$fdata='finaldata.txt';
12
13#opening the temporary file 'tempdat.tmp' and assigning a handle to it.
14open(TDFILE,">$tdfile");
15
16#Opening and reading the .c and .h files                 
17while(defined($indata=glob("*.dat")))
18{
19  #assigning a handle to the file as it is opened
20  open(DATAF,"$indata");
21  while(<DATAF>)
22  {     
23    if($_=~/>>refer/)
24    {
25      #printing the output in a "filename(tab)reference" format
26      $_=~s/\W*//;
27      $_=~s/\W*$//;     
28      print TDFILE "$indata\t$_\n";
29    }
30   }
31}
32
33#close the two files
34close(DATAF);
35close(TDFILE);
36
37open(TDFILE,"$tdfile");
38open(FDATA,">$fdata");
39
40while(<TDFILE>)
41{
42  $_=~s/\n$//;
43  if($_=~/refercon/)
44  {
45    $_=~s/.*\s*.*refercon\s/ /;
46    print FDATA "$_";      #writing lines to 'final.txt'
47  }
48  else
49  {
50    $_=~s/\t*refer(\t|\s*)/\t/;
51    print FDATA "\n$_";
52  }
53}
54
55#closing the two files
56close(FDATA);
57close(TDFILE);
58unlink($tdfile);        #delete the temporary file 'tempdat.tmp
59
60print "The file created is:\n";
61print "$fdata.\n\n";
62
63
64
65
66
67
68
69
70
71
72
Note: See TracBrowser for help on using the browser.