varFoo = bar
some text
some text
...
####
# command line perl script to put all "var2 = 3" chunks into a separate file:
perl -ne 'BEGIN{ $/="\n" } print if /var2 = 3/' input > var2_3.output
# just do the opposite (change "if" to "unless") to save the other chunks elsewhere