in reply to can u suggest a regex for this ?

Hello misterperl

also flip-flop can be used (look for the scalar context usage):

use strict; use warnings; while (<DATA>){ print /^cat/ .. /^\^cat/ ? "#$_" : $_; } __DATA__ mouse cat 1 2 3 ^cat deer eel cat furbaby elk ^cat dog fish

L*

PS ^\^ is actually a cat :)

PPS overlooked previous answer was already using flip-flop.. let rephrase: you can also use flip-flop directly :)

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.