News for hackers. Stuff that matters.
Re:Scripting with Go: A Modest Proposal by sgarland on Sunday August 20, 2023 @12:02PM (#37200396)
That's a fair criticism. I know Perl can do pretty amazing things with text, but I've never bothered to learn it.

EDIT: I decided to ask GPT-4 to translate the gawk script to Perl. I make zero claims that this is ideal (as stated, I don't know Perl at all), but it _does_ produce the same output, but slightly slower than the gawk script.

  $ hyperfine "perl -lane '\$ips{\$F[0]}++; END {print \"\$ips{\$_} \$_\" for (sort {\$ips{\$b} <=> \$ips{\$a}} keys %ips)[0..9]}' fake_log.txt"
  Benchmark 1: perl -lane '$ips{$F[0]}++; END {print "$ips{$_} $_" for (sort {$ips{$b} <=> $ips{$a}} keys %ips)[0..9]}' fake_log.txt
  Time (mean ± σ):      1.499 s ±  0.006 s    [User: 1.447 s, System: 0.050 s]
  Range (min … max):    1.490 s …  1.507 s    10 runs
Re:Scripting with Go: A Modest Proposal by ajross on Sunday August 20, 2023 @02:04PM (#37201515)
I would have gone with an iteratively-built list, FWIW, and avoided the overhead in parsing fields the script won't use:

    perl -e 'for $i (<>) { $i =~ s/ .*//; push @list, $i; }; print(sort(@list));'