RE: Inplace edit regex fun

2003-10-08 Thread Dan Muey
> qx interpolates variables. by the time $1 gets to perl, it's > already gone. > try: > > print qx(perl -pi -e 's/^$u:hello:([^:]*):/$u:goodbye:\$1/;' file); > That did it! Thanks a million for pointing that out! > why not simply: > > [panda]$ perl -pi -e > 's/^datax:hello:([^:]*):/datax:go

RE: Inplace edit regex fun

2003-10-08 Thread david
Dan Muey wrote: >> First, (.*) is very greedy. You might want to limit it in >> some way, possibly with a ? modifier like (.*?), possibly by >> looking for less than . such as ([^:]*) -- anything but a colon. >> >> Second, the backwack numbers \1 .. \9 are only for the >> matching portion of a s

RE: Inplace edit regex fun

2003-10-08 Thread Dan Muey
> First, (.*) is very greedy. You might want to limit it in > some way, possibly with a ? modifier like (.*?), possibly by > looking for less than . such as ([^:]*) -- anything but a colon. > > Second, the backwack numbers \1 .. \9 are only for the > matching portion of a subsitution. You mus

Re: Inplace edit regex fun

2003-10-08 Thread Casey West
It was Wednesday, October 08, 2003 when Dan Muey took the soap box, saying: : Howdy list: : : Trying to do an inplace edit: : : perl -pi -e 's/whatever/newstuff/;' /file/path/here : : What I need to do is replace certain parts of the line for instance: : : : s/^$var:(.*):123:def/$var:\1:456:g

Inplace edit regex fun

2003-10-08 Thread Dan Muey
Howdy list: Trying to do an inplace edit: perl -pi -e 's/whatever/newstuff/;' /file/path/here What I need to do is replace certain parts of the line for instance: s/^$var:(.*):123:def/$var:\1:456:ghi/; Soo if a line matches the $var at the beginning a colon, some stuff, a colon, 123, a colo