# Manipulating definitions while reading them with Get

In order to read in a definition with certain parameters replaced by appropriate values I can use for example

Block[{a=1.1,b=2.2}, Get["file"]]


where "file" is a file containing the definitions (which contain a and b on the RHS). This works well and is fast. Now is there a way to do something similar if I want to replace a string. So basically, Block[{"string"="bla"},Get["file"]] (but then in a way that actually works of course).

Try this:

Get @ StringToStream @ StringReplace["\"string\"" -> "\"bla\""] @ Import["file", "Text"]


Alternatively you can read a package step by step like in a/124670 but instead of:

Sow[ Interpretation @@ {withContext[expr], expr} ];
ReleaseHold[expr];


do

ReleaseHold[expr /. "string" -> "bla"]