in reply to Where is now the extract numeric id in the parenthesis

I would like to give you some general remarks:-

1. Use three argument open for opening a file like

open(my $fh, '<', "input.txt") or die $!;

2. if you reading a file line by line then no need to put lines into array and then apply foreach loop on it, you can use while loop for that like

while(my $line = <$fh>){ #insert data }