perl -anE 'say($F[0]) if /error/' big.log >/dev/null 0.85s user 0.02s system 99% cpu 0.867 total
mawk '/error/ {print $1}' big.log > /dev/null 0.21s user 0.03s system 99% cpu 0.246 totalhttps://github.com/mikebrennan000/mawk-2/blob/master/about-m...
Plus if you're going to talk about older builds of mawk then you can't really ignore older versions of Perl as well (which was originally released in 1987). Otherwise you're not making a fair comparison.
I should add, I have absolutely nothing against mawk. It just wasn't something available on any of the POSIX systems I used in the 90s. tbh even now it's an optional install but at least it is an easier install than it was in the 90s.
Local variables unfortunately can only be obtained in the form of extra parameters (which are not passed by the caller).
function foo(x, y, # params
z, w) # locals
{
}
There is a convention to separate the two by some obvious whitespace.There are no block scoped-locals: all locals have to go into the parameter list. Initial values cannot be specified.
(Speaking of which, there are hacks for simulating the feature of optional parameters with defaulted values.)
In GNU Awk, from the following experiment, the scope appears lexical:
function bar()
{
return x
}
function foo(x)
{
x = 3
return bar();
}
BEGIN { x = 42; print foo(); }
The output is 42, which means that the "x = 3" assignment to the local variable x in foo does not affect the access to the free variable x in bar, as it would under dynamic scope.
Also Perl has better support for programming-in-the-large than awk, with modules, lexical scoping and CPAN.
Booking.com, IMDB and I believe the Amazon frontend are all written in Perl.