I see you are cross posting ( https://stackoverflow.com/questions/76379004/how-to-parse-multi-line-bash-func-in-perl-script
which we do not really approve of, read the forum FAQ/guidelines.
Once your other posters have answered (or rejected) your request you may come back for advice.