in reply to Re^2: hackerrank.com question
in thread hackerrank.com question

It seems the behaviour depends on whether the file ends in a newline or not, not on the Perl version. That's because the final [^\w\.] has nothing to match if there's no newline.

If you are curious, here's my solution from three years ago:

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^4: hackerrank.com question
by writch (Sexton) on Sep 27, 2018 at 15:47 UTC

    But that code actually works. It returns the expected results, including the terminal email address. It just doesn't on hackerrank.com. It did when I changed [^\w\.] to (?:$|[^\w\.]), which is what the regex site needed.

    If it's not a Perl version thing, then it's likely some kind of emulator issue on their part, or perhaps the regex web site is wrong in not matching it. It seems to me that EOD is not a word, personally.

      Per what choroba said (perhaps privately) regarding the source document, I did a hexdump of the source document, and found that vi was appending, but not presenting, a newline in that data set.

      If I explicitly added a newline, there were two terminal newline characters in hexdump.

      Mystery solved, sort of, but that looks like a bug in vim. I always trusted it before.
        Not a bug, but a 'feature'. Apparently, vim automatically appends every line with CR/LF characters per whatever file mode is set. The suggested path to fixing this is to use the ':set binary' command in conjunction with ':%!xxd' and ':%!xxd -r' to remove this extra character.