Thursday, March 13, 2014

SearchInsert.pl Script for Lucy Li

~/doc/Lucy/SearchInsert.pl.html
 1 #!/usr/bin/perl -w
 2 #===============================================================================
 3 #
 4 #         FILE:  searchInsert.pl
 5 #
 6 #        USAGE:  ./searchInsert.pl searchfile file_to_be_inserted
 7 #
 8 #  DESCRIPTION:  search each line of file searchfile, and insert file
 9 #                file_to_be_inserted after each line containing string "meas"
10 #
11 #      OPTIONS:  ---
12 # REQUIREMENTS:  ---
13 #         BUGS:  ---
14 #        NOTES:  ---
15 #       AUTHOR:   (), <>
16 #      COMPANY:  
17 #      VERSION:  1.0
18 #      CREATED:  11/30/12 15:43:32 PST
19 #     REVISION:  ---
20 #===============================================================================
21 
22 use strict;
23 use warnings;
24 
25 my $s_file = shift;
26 my $i_file = shift;
27 open(SF,"$s_file") || die "$!\n";
28 while(){
29   s/\x00/x/g;    #remove end of string
30   print;
31   if(m/meas/){   #insert file after lines with "meas"
32    print `cat $i_file`;
33   }
34 }
35 close(SF);
36 

No comments:

Post a Comment