home *** CD-ROM | disk | FTP | other *** search
/ HTML - Publishing on the Internet / html_cdrom.iso / tools / html / windows / check / metachar.pl < prev    next >
Perl Script  |  1995-01-14  |  594b  |  18 lines

  1. #!/usr/local/bin/perl
  2. #metachar.pl Trivial Perl program to protect HTML/SGML "&<>" meta-characters.
  3. #
  4. # Typical use:
  5. #
  6. #   perl htmlchek.pl infile.text > outfile.htmltext
  7. #
  8. #   This program protects the HTML/SGML metacharacters `&', `<' and `>' by
  9. # replacing them with the appropriate entity references; it is useful for
  10. # importing plain text into an HTML file.
  11. #
  12. eval "exec /usr/local/bin/perl -S $0 $*"
  13.     if $running_under_some_shell; # this emulates #! processing on NIH machines
  14. while (<>) {
  15.     if (/[><&]/) {s/&/&/g; s/>/>/g; s/</</g;}
  16.     print $_;}
  17. ##EOF
  18.