> 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 must use their > variable representations, $1 .. $9 in the replacement portion. >
Thanks for the info Casey: Ok I tried doing this: 'file' has one line datax:hello:2: my $u = 'datax'; print qx(perl -pi -e 's/^$u:hello:([^:]*):/$u:goodbye:$1/;' file); And file changes to: datax:goodby:: But I get a 'use of uninitialized value (IE about $1) Same thing with \1 instead of $1 (except I get a space in between colons and no error) so I need a letter after the regex or something (e or x or ??)? I thought I messed up the regex in () but so I did this to rule that out: my $u = 'datax'; print qx(perl -pi -e 's/^$u:hello:(2):/$u:goodbye:$1/;' file); Same exact result, it still didn't assign $1 or \1 the value of '2'. What could I be missing?? I'm going crazy!!! Thanks Dan > Casey West > > -- > The goal of Computer Science is to build something that will > last at least until we've finished building it. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]