Insert new line of text into Odbc.ini file

I am new to Perl. I wrote a Perl program that inserts text "EnableScrollableCursors=3" after a section of contexts in the odbc.ini file matches a variable in an array list. "EnableScrollableCursors=3" is added to a newline before whitespaces separate each section of contexts in the odbc.ini.

Examples are in the following attachments:
before_odbc.txt
after_odbc.txt

1) before_odbc.txt is how the odbc.ini current looks before changes.

2) after_odbc.txt is how the odbc.ini needs to look after EnableScrollableCursors=3 is added to each section of contexts that matches the list in the array.

Here is my code:

#!/usr/bin/perl -w

# array search terms


my @match=(AMCSmartk_  AMCSmartfBC_  AMILX_  IHI_ETA_  ASO_   UHACSOI_);

my $filename = '/tmp/before_odbc.txt';
 
my @arr = 'EnableScorllableCursors=3';

open (FILE,  $filename) or die "unable to open $filename: !";
local last = '';
local $^I ='.bak';
While (<FILE>)

#step 1: if one of variable listed in the array matches the variable in the before_odbc.txt file then insert EnableScorllableCursors=3 
#into a newline. EnableScorllableCursors=3 is inserted between the last line of contexts and before the whitespaces in the file. Then move to the next section of contexts and loop through step 1 process again.

foreach my $match  (@match) {
  
  if ($match==/FILE/) {
 
print << @arr "\n";

if $last;

next;

  }
# step 2: if any of variables in the array list does not matches any of #variables in the before_odbc.txt file then move next

else
if ($match=~/FILE/) {
print;

if $last;

next;
    close FILE;
}

print "Finished \n";