in reply to Newbie: uses/limits of perl in editing files
That will call user-written subroutine mysub every time HEADER and REMARK are found in the text. The argument passed is the text matched inside (). Whatever is returned by mysub will replace the token. It probably would not be worth it for the simple substitution you mentioned, but for more complex combinations it can be very powerful.$line =~ s/(HEADER|REMARK)/mysub($1)/ge;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Newbie: uses/limits of perl in editing files
by wherethewild (Novice) on Nov 23, 2007 at 15:02 UTC | |
by RaptorRex (Acolyte) on Nov 23, 2007 at 17:06 UTC |