Is there any way (in perl) to do a substitution like if you find this,
replace it with that, else replace it with something else?
For example I have a bunch of lines like:
initial 256
initial 512
initial 1024
initial 2048
I want to match on /initial\s+\d+/ and replace 256 with 4092 but replace all
the other numbers with 1024. I don't know (ahead of time) what the numbers
are, I just know I want to replace a specific number with X and the rest
with Y.
I tried building a hash like:
%replace = (526=>'4092')
and then do:
s/initial\s+(\d+)/initial $replace{$1}/g
but obviously it fails as soon as it finds a key that doesn't exist, but its
sorta what I want
Does this make sense
Jay
Jay Strauss
[EMAIL PROTECTED]
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com