3 foreach $file ( split(/\n/, `find . -depth -print`) ) {
4 next unless $file =~ /(cgi|html)$/;
5 open(F,$file) or die "can't open $file for reading: $!";
7 #print "$file ". scalar(@file). "\n";
9 $newline = ''; #avoid prepending extraneous newlines
10 $all = join('',@file);
15 while ( length($all) ) {
17 if ( $mode eq 'html' ) {
19 if ( $all =~ /^(.+?)(<%=?.*)$/s && $1 !~ /<%/s ) {
23 } elsif ( $all =~ /^<%=(.*)$/s ) {
29 } elsif ( $all =~ /^<%(.*)$/s ) {
30 $w .= $newline; $newline = "\n";
34 #avoid newline prepend fix from borking indented first <%
36 $w .= "\n" if $w =~ /.+\z/;
39 } elsif ( $all !~ /<%/s ) {
43 warn length($all); die;
47 } elsif ( $mode eq 'perlv' ) {
49 if ( $all =~ /^(.*?%>)(.*)$/s ) {
55 die "unterminated <%= ??? (in $file):";
57 } elsif ( $mode eq 'perlc' ) {
59 if ( $all =~ /^([^\n]*?)%>(.*)$/s ) {
65 if ( $all =~ /^([^\n]*)\n(.*)$/s ) {
75 system("chmod u+w $file");
76 select W; $| = 1; select STDOUT;
77 open(W,">$file") or die "can't open $file for writing: $!";