a perl question

Tom Christiansen tchrist at convex.COM
Sun Nov 12 04:52:24 AEST 1989


I just got mail from Larry Wall who pointed out that you need 
to use \1 in the LHS of the substitute.  He said:

|You want something like this:
|
|    s/(.)\010\1/<<<$1>>>/g;
|    s/>>><<<//g;
|
|where <<< and >>> can be anything that don't occur in the text.
|
|Within a pattern you want to use \1, not $1, because $1 means interpolate
|the previous pattern match.

Which makes it work.  When you're done, change the <<< and >>> into
start-standout and end-standout, like this:

    s/<<</$SO/g;  # or s/<<</\033[1m/g; or whatever
    s/>>>/$SE/g;


--tom

    Tom Christiansen                       {uunet,uiucdcs,sun}!convex!tchrist 
    Convex Computer Corporation                            tchrist at convex.COM
		 "EMACS belongs in <sys/errno.h>: Editor too big!"



More information about the Comp.unix.questions mailing list