I believe this is called "bug emulation". awk itself has the same problem.
(It is possible that this was not considered a bug when first implemented.
I can imagine someone wishing to override the BEGIN section from the command
line. Let us be charitable, and call it a misleading feature :-)
I chose not to emulate this particular misleading feature in the awk-to-perl
translator. The produced perl script evaluates the foo=bar switches before
doing the "BEGIN" stuff. If you want the other behavior, you can just move
the line that does that, which says
eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
down below the stuff derived from BEGIN.
Oddly enough, in the version of nawk I have access to, it is documented
to have the buggy behavior, but, in fact, works right. Go figure.
Larry Wall
lw...@jpl-devvax.jpl.nasa.gov