in reply to Re: Extracting /regex/mg in a while loop
in thread Extracting /regex/mg in a while loop

Nice work!

About that CAVEAT for Windows: File::Spec covers that in a portable way: $devnull = File::Spec->devnull();

  • Comment on Re^2: Extracting /regex/mg in a while loop

Replies are listed 'Best First'.
Re^3: Extracting /regex/mg in a while loop
by kcott (Archbishop) on Oct 10, 2023 at 16:20 UTC

    G'day haj,

    ++ Thanks for the tip.

    For anyone looking for portability, DRYness, and an easy way to add more tests, replace all the code prior to the start of the subroutine definitions with:

    Update: I made an error with the original code I posted. I've stricken that code and replaced it with a rewrite which works correctly. That rewrite includes all of the additional features: "portability, DRYness, and an easy way to add more tests". The code I posted below is no longer valid; I've stricken it and placed it in a spoiler. The final paragraph, about adding new tests, is still valid: I left it unchanged.

    For more tests, add your subroutine and its name to @bench_names; the rest is done for you.

    — Ken