guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 1.4 build problems (sorry!)


From: Thien-Thi Nguyen
Subject: Re: 1.4 build problems (sorry!)
Date: Fri, 22 Feb 2002 11:01:33 -0800

   From: "Peter C. Norton" <address@hidden>
   Date: Fri, 22 Feb 2002 04:22:03 -0800

   I recall asking for help when I did that bit of perl, but nothing
   really came of it.  Anyone want to help my practical scheme skills?

i've appended the perl script below so we can collaboratively rework the
beast.  it looks like the heart is the "$/ = foo" lines.  what does that
mean in perl?

thi

__________________________________________
#!/usr/bin/perl

# A single purpose script.  It takes my template page, and applies it
# to a file.  That file has the following:

# A <section_name>...</section_name> pair that will appear in the title and
# the h1.

# A single <local_nav> </local_nav> pair that gets substitued into the page,
# and a single <main_content> </main_content> pair.

# The tempate file has to have local_nav appear before main_content.  Both
# must be present.  On the template side, there must be no content between the
# tags that the victim will populate.

# The first argument is the template file, the second is the file it's to be
# applied to the third is the output filename

my $output_page, $line;
my @out_buffer;

open(TEMPL, "$ARGV[0]") || die("Couldn't open template file\n");
open(VICTIM, "$ARGV[1]") || die("Couldn't open content file\n");


# local_nav section
my $old_IFS = $/;

$line = <VICTIM>; # garbage, don't need anything before the tag.
$line =~ /\<section_name\>(.*)\<\/section_name\>/i;
$section_name = $1;
$/ = '<local_nav>';
my $tmpl_preamble = <TEMPL>; # no preamble in content
$/ = '</local_nav>';
$line = <TEMPL>; # garbage, not to be used - if there's even anything there.
my $victim_local_nav = <VICTIM>;
$/ = '<main_content>';
my $tmpl_content = <TEMPL>;
my $line = <VICTIM>; # garbage
$/ = '</main_content>';
$line = <TEMPL>;
my $victim_content = <VICTIM>;
undef($/);
my $the_rest = <TEMPL>;


$tmpl_preamble =~ s/\<section_name\>.*\<\/section_name\>/$section_name/gi;

# Do this at the end
open(TARGET, ">$ARGV[2].new") || die("Couldn't open output file\n");
print(TARGET $tmpl_preamble, "\n");
print(TARGET $victim_local_nav, "\n");
print(TARGET $tmpl_content, "\n");
print(TARGET $victim_content, "\n");
print(TARGET $the_rest, "\n");
rename("$ARGV[2].new", "$ARGV[2]");

# eof



reply via email to

[Prev in Thread] Current Thread [Next in Thread]