in reply to Re^5: Writing tests when you don't know what the output should be
in thread Writing tests when you don't know what the output should be

One other question about your example if I might impose. That second to last line has me scratching my head. The grep $0 is nothing I'm familiar with and the regex has me baffled as well. Thanks!

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re^7: Writing tests when you don't know what the output should be
by choroba (Cardinal) on May 19, 2016 at 15:57 UTC
    my ($itself) = grep { 0 <= index $0, $_ } $checker->dir->read;

    See $0, index, grep. In other words, the read method returns the contents of the directory, grep then tries to find a file name $_ that's contained in the test script's path (it's buggy, as it doesn't check whether the preceding character is a slash).

    m{(?:^|/)\Q$_\E$}x

    The regex fixes the issue: it checks that the filename is present in the script's name from the beginning (^) or a slash to the end ($). \Q quotes special characters in the filename so it matches literally.

    ($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,