Hacker News new | ask | show | jobs
by ash_gti 3234 days ago
So, a fairly simple change to this will bring down the time to a few ms (86 ms on my computer)

  time yes | head -n1000000 | perl6 -e 'for $*IN.readchars { .subst("y", "n").print }’
Its slightly more complicated because I’m having it read the input in a chunk instead of on a per-line basis and I’m using subst on a literal instead of a regex.