#! /usr/local/bin/perl # replace Hebrew text in web pages by GIF images # read command line parameters while ($param = shift) { if ($option) { $option{$option} = $param; $option = ''; } elsif ($param =~ /^-(.)(.*)$/) { if ($2) { $option{$1} = $2; } else { $option = $1; }; } else { $option{'i'} = $param; last; }; }; if ($option) { die "missing value for option \"$option\""; }; # open files if ($option{'i'}) { if (! -f $option{'i'} && -f "$option{'i'}.hebweb") { open (INP, "<$option{'i'}.hebweb") || die "unable to open input file \"$option{'i'}.hebweb\""; $outp = "$option{'i'}.html"; } else { open (INP, "<$option{'i'}") || die "unable to open input file \"$option{'i'}\""; if ($option{'i'} =~ /.hebweb$/) { $outp = "$`.html"; } else { $outp = "$option{'i'}.html"; }; }; } else { die "no input file"; }; if ($option{'o'}) { open (OUTP, ">$option{'o'}") || die "unable to open output file \"$option{'o'}\""; } else { chmod (0600, $outp) || die "unable to chmod file \"$outp\""; open (OUTP, ">$outp") || die "unable to open output file \"$outp\""; }; if ($option{'u'}) { $url = $option{'u'}; if ($url && $url !~ /\/$/) { $url .= '/'; }; }; if ($option{'d'}) { $dir = $option{'d'}; if ($dir && $dir !~ /\/$/) { $dir .= '/'; }; } elsif ($option{'i'} =~ /\/[^\/]+$/) { $dir = "$`/"; } else { $dir = '.'; }; # process file while () { chop; while (/([^<]*)<\/HEBREW>/) { $pre = $`; $text = $1; $post = $'; if ($pre) { $pre .= "\n"; }; open (PIPE, "mc2xbm -e '$text' -d $dir|"); read (PIPE, $tag, 500); close (PIPE); if ($url) { $tag =~ /SRC=\"/; $tag = "$`SRC=\"$url$'"; }; print (OUTP "$pre$tag"); $_ = $post; }; print (OUTP "$_\n"); }; close (OUTP); if (! $option{'o'}) { chmod (0400, $outp); };