Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!snorkelwacker!think!cs.utexas.edu!uunet!mcsun!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: a perl question Message-ID: <4524@ski.cs.vu.nl> Date: 13 Nov 89 20:56:08 GMT References: <3002@convex.UUCP> Reply-To: maart@cs.vu.nl (Maarten Litmaath) Distribution: comp Organization: VU Informatica, Amsterdam Lines: 37 At first I wrote it in sed: ----------8<----------8<----------8<----------8<----------8<---------- : top s/\(\n.*\)\n\(.\)^H\2/\1\2\ / t top s/\(.\)^H\1/\ \1\ / t top s/\n\([^\n]*\)\n/${bold}\1${endbold}/g ----------8<----------8<----------8<----------8<----------8<---------- Then I ran s2p on the script -> wrong perl script! ('\n' is handled incorrectly.) A rewrite in perl: ----------8<----------8<----------8<----------8<----------8<---------- #!/usr/local/bin/perl eval "exec /usr/local/bin/perl -S $0 $*" if $running_under_some_shell; $SO = "\033[7m"; $SE = "\033[m"; line: while (<>) { while (1) { while (s/(\n.*)\n(.)\010\2/$1$2\n/) { ; } last if !s/(.)\010\1/\n$1\n/; } s/\n(.*)\n/$SO$1$SE/g; print; } -- "Richard Sexton is actually an AI program (or Construct, if you will) running on some AT&T (R) 3B" (Richard Brosseau) | maart@cs.vu.nl, mcsun!botter!maart