"BEGIN {" is used to detect Perl scripts (when it's valid in other languages)
I've noticed shell scripts like this (and others that call awk very early), if not given an extension, will be detected as application/x-perl
.
#!/bin/sh
awk 'BEGIN { print $0 }'
After some investigation, I think this has to do this line:
https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/master/data/freedesktop.org.xml.in#L3423
It treats BEGIN {
as a string that's specific to Perl.