Insert few lines above a match using sed, and within a perl file.

Greetings all,

I am trying to match a string, and after that insert a few lines above that match.
The string is "Version 1.0.0". I need to insert a few lines ONLY above the first match (there are many Version numbers in the file). The rest of the matches must be ignored. The lines I need to insert are (above Version 1.0.0):

Version 2.0.0 
-------------
2012-01-11 - user_name
prod 2.0.0

This needs to be done in all files named VERSIONINFO recursively from the top level folder.
I have tried to do this in a perl file:

#-------------
@readme_files = `find . -name "VERSIONINO"`;
foreach $readmes (@readme_files)        {
chomp ($readmes);
        
$ver_match = `sed -n '/^Version [0-9].[0-9].[0-9]/{p;q;}' "$readmes"`;
        if ($ver_match)
                {push (@vermatch,  $ver_match);
`sed  -i '/"$ver_match"/ i \Version 2.0.0\\n-------------\\n2012-01-15 - user_name\\nprod 2.0.0\\n' "$readmes"`;
}
        else {
                push (@no_vermatch, $readmes);
                }
}
print "Versions found @vermatch\n";
print "Files with no version numbers @no_vermatch\n";

But the problem is with SED that does the actual insert. the error is:

sed: -e expression #1, char 15: unterminated address regex

sed, that picks out the first match works fine, the insert part does not. I tried escaping characters, but have not been successful. I believe I need to escape some characters in the sed insert command, but have been lost now.

Would appreciate any input to solve this.
Thanks in advance,

Output in green.

$ cat inputfile
Version 1.0.0

Version 1.0.0

Version 1.0.0
$
$ sed '0,/Version 1.0.0/i Version 2.0.0\n-------------\n2012-01-11 - user_name\nprod 2.0.0' inputfile
Version 2.0.0
-------------
2012-01-11 - user_name
prod 2.0.0
Version 1.0.0

Version 1.0.0 

Version 1.0.0 
$
$

Please use code tags when posting sample input/output or code.

Your problem is the quotes:

sed  -i '/"$ver_match"/ i YourString'

The variable does not get expanded, because it's inside the single quotes, taken as literal. Turn the single quotes off and on:

sed  -i '/'"$ver_match"'/ i YourString'

and you should be good to go.

However this can be simplified quite a bit. All this perl stuff is not needed, since it only calls external tools (find, sed). You can do without:

v="Version 1.0"; 
str="Version 2.0.0\x0a-------------\x0a2012-01-15 - user_name\x0aprod 2.0.0"
find .  -name "VERSIONINFO" | xargs sed -i '/^'"$v"'/ i '"$str" 

The \x0a is a hex code of the newline char.
xargs will feed all the files to sed as arguments, so sed is actually called like:

sed -i <command> ./path1/VERSIONINFO ./path2/VERSIONINFO ./path3/VERSIONINFO