3 $DIFF = "/usr/bin/diff";
4 $PERL = "/usr/bin/perl";
10 print start_html("File Diff Example");
11 print "<strong>Version </strong>$CGI::VERSION<p>";
14 <H1>File Diff Example</H1>
15 Enter two files. When you press "submit" their diff will be
20 # Start a multipart form.
21 print start_multipart_form;
22 print "File #1:",filefield(-name=>'file1',-size=>45),"<BR>\n";
23 print "File #2:",filefield(-name=>'file2',-size=>45),"<BR>\n";
24 print "Diff type: ",radio_group(-name=>'type',
25 -value=>['context','normal']),"<br>\n";
26 print reset,submit(-name=>'submit',-value=>'Do Diff');
29 # Process the form if there is a file name entered
30 $file1 = param('file1');
31 $file2 = param('file2');
34 if ($file1 && $file2) {
35 $realfile1 = tmpFileName($file1);
36 $realfile2 = tmpFileName($file2);
38 print "<H2>$file1 vs $file2</H2>\n";
41 $options = "-c" if param('type') eq 'context';
42 system "$DIFF $options $realfile1 $realfile2 | $PERL -pe 's/>/>/g; s/</</g;'";
50 <A HREF="../cgi_docs.html">CGI documentation</A>
53 <A HREF="/~lstein">Lincoln D. Stein</A>
55 Last modified 17 July 1996
62 my($safe) = $name=~/([a-zA-Z0-9._~#,]+)/;
64 print "<strong>$name is not a valid Unix filename -- sorry</strong>";