J
john_pataki
I want to reproduce a string search and replace between to arrays that
I have done in perl using very little code. I am not sure how best do
this without overdoing it... I have the outline of the code written
below - I just need to know what is my next best steps to complete it
-- or a suggestion if what I have so far is not correct. Thanks, john
My perl script basically inserts some postscript code for a watermark
into another postscript file.
Here is basic idea in psuedo perl ocode:
@infile = read_file("c:\\my_drawing.ps");
@watermark_code = read_file("c:\\watermark.ps");
# This is the core filter code
foreach $line (@infile) {
if ($line =~ /showpage/i) { # find line with showpage
$line =~ s/showpage//i; # remove showpage from line
push @outfile,$line; # add line from infile
push @outfile,"@watermark"; #insert all lines of watermark
} else { # all other lines in infile
push @outfile,$line; # add line from infile
} # end if and else
} # end foreach
The help I need is just with the above loop. Here is my current C code
I have written to get ready to do this loop.
I left out the read_ps_file function to make this email smaller...
int merge_watermark (void)
{
int watermark_lines;
int current_ps_lines;
int line;
char **watermark_code;
char **current_ps_code;
char watermark_file[256] = "c:\\temp\\watermark.ps";
char current_ps_file[256] = "c:\\temp\\18.ps";
watermark_lines = read_ps_file(watermark_file,watermark_code);
current_ps_lines = read_ps_file(current_ps_file,current_ps_code);
for (line=0;line<=current_ps_lines;line++) {
// merge code here...
} // end
}
I have done in perl using very little code. I am not sure how best do
this without overdoing it... I have the outline of the code written
below - I just need to know what is my next best steps to complete it
-- or a suggestion if what I have so far is not correct. Thanks, john
My perl script basically inserts some postscript code for a watermark
into another postscript file.
Here is basic idea in psuedo perl ocode:
@infile = read_file("c:\\my_drawing.ps");
@watermark_code = read_file("c:\\watermark.ps");
# This is the core filter code
foreach $line (@infile) {
if ($line =~ /showpage/i) { # find line with showpage
$line =~ s/showpage//i; # remove showpage from line
push @outfile,$line; # add line from infile
push @outfile,"@watermark"; #insert all lines of watermark
} else { # all other lines in infile
push @outfile,$line; # add line from infile
} # end if and else
} # end foreach
The help I need is just with the above loop. Here is my current C code
I have written to get ready to do this loop.
I left out the read_ps_file function to make this email smaller...
int merge_watermark (void)
{
int watermark_lines;
int current_ps_lines;
int line;
char **watermark_code;
char **current_ps_code;
char watermark_file[256] = "c:\\temp\\watermark.ps";
char current_ps_file[256] = "c:\\temp\\18.ps";
watermark_lines = read_ps_file(watermark_file,watermark_code);
current_ps_lines = read_ps_file(current_ps_file,current_ps_code);
for (line=0;line<=current_ps_lines;line++) {
// merge code here...
} // end
}