<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/">
  <channel about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss">
    <title>gmane.comp.lang.perl.qotw.discuss</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss</link>
    <description/>
    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>1</syn:updateFrequency>
    <syn:updateBase>1901-01-01T00:00+00:00</syn:updateBase>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2644"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2643"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2642"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2641"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2640"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2639"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2638"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2637"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2636"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2635"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2634"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2633"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2632"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2631"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2630"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2629"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2628"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2627"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2626"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2625"/>
      </rdf:Seq>
    </items>
    <image rdf:resource="http://gmane.org/img/gmane-25t.png"/>
    <textinput rdf:resource=""/>
  </channel>
  <image rdf:about="http://gmane.org/img/gmane-25t.png">
    <title>Gmane</title>
    <url>http://gmane.org/img/gmane-25t.png</url>
    <link>http://gmane.org</link>
  </image>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2644">
    <title>[QUIZ] Perl 'Hard' Quiz of the Whatever #2008-03-28 - Solving Kakuro</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2644</link>
    <description>IMPORTANT: Please do not post solutions, hints, or other spoilers
until at least 60 hours after the date of this message.  Thanks.

Kakuro (a.k.a Cross-sums) is a kind of puzzle game:

http://en.wikipedia.org/wiki/Kakuro

In it, one fills in squares in a crossword-like grid that sum to their sums. 
One can fill in the digits from 1 to 9, and no digit can be repeated twice.

Your object is that given a Kakuro board in a text format described below, 
then output the final solution.

You can find some sample layouts from kakuro.com here: 
http://www.shlomifish.org/Files/files/text/kakuro.com-layouts/ 

and there's a new daily puzzle everyday there. (Requires Flash) There are also 
some more layouts googleable or on the wikipedia page.

The layout has the following format:

1. It consists of $Height lines.

2. Each line has $Width squares. Whitespace inside each line is ignored.

3. Each square starts with [ and ends with ]. 

4. A square that contains a \ is a blocked square (i.e: a square that cannot 
have any</description>
    <dc:creator>Shlomi Fish</dc:creator>
    <dc:date>2008-03-27T22:38:08</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2643">
    <title>Re: [QUIZ] Perl 'Medium' Quiz of the Whatever #2008-02-28 - Kakuro Digit Sums</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2643</link>
    <description>
[ Haven't got the original mail, so piggying here ]

"Any programming problem can be solved by adding another layer of 
indirection".

Here's my solution. Run this program to produce a program which 
satisfies the requirements. I also expect this solution to be the 
fastest around.... :-)

Regards,
M4


#!/usr/bin/perl

use strict;
use warnings;

sub get_digits_sum {
  my ($sum, $num_places) = &lt; at &gt;_;
  return [solve($sum, $num_places, 0, 0)];
}

sub solve {
  my ($sum, $places_left, $running, $previous, &lt; at &gt;partial) = &lt; at &gt;_;
  return map solve($sum, $places_left-1, $running+$_, $_, &lt; at &gt;partial, $_),
    ($previous+1..($sum - $running &gt; 9 ? 9 : $sum - $running))
      if $places_left;
  return $sum == $running ? [&lt; at &gt;partial] : ();
}


print &lt;&lt;'EOT';
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests =&gt; 8;

my %sol = (
EOT

use Data::Dumper;
for my $sum (1..45) {
  print "$sum =&gt; {\n";
  for my $places (1..9) {
    my $answer = get_digits_sum($sum, $places);
    if (&lt; at &gt;$answer) {
      print "  $places =&gt; \n";
</description>
    <dc:creator>Martijn Lievaart</dc:creator>
    <dc:date>2008-03-07T08:34:14</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2642">
    <title>Re: [QUIZ] Perl 'Medium' Quiz of the Whatever #2008-02-28 - Kakuro Digit Sums</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2642</link>
    <description>In Haskell, FWIW:

    get_digits_sum _ 0 = []
    get_digits_sum 0 _ = []
    get_digits_sum goal n = find goal n [1..9]
      where find _ _ [] = []
            find goal n (d:ds)
              | n == 1 &amp;&amp; d == goal = [[d]]
              | otherwise = with ++ find goal n ds
                  where with = map (d:) $ find (goal - d) (n - 1) ds

Greg

</description>
    <dc:creator>Greg Bacon</dc:creator>
    <dc:date>2008-03-06T14:44:52</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2641">
    <title>Re: [QUIZ] Perl 'Medium' Quiz of the Whatever #2008-02-28 - Kakuro Digit Sums</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2641</link>
    <description>
Here's my solution.  It, too, is recursive, but unlike M. Fish's, I've
used a secondary accumulator parameter.

    -- michael.

--
#!perl
use strict;
sub get_digits_sum {
    my ($sum, $left, $soln, &lt; at &gt;ns) = &lt; at &gt;_;
    return 
if $sum == 0;
    return [get_digits_sum($sum, $left, [], 1..9)] 
if !defined $soln;
    return (grep {$sum==$_} &lt; at &gt;ns) ? [&lt; at &gt;$soln, $sum] : () 
if $left == 1;
    my &lt; at &gt;rv;
    for my $n (&lt; at &gt;ns) {
return &lt; at &gt;rv 
    if $n &gt; $sum; # rest won't work either
push &lt; at &gt;rv, get_digits_sum($sum-$n, $left-1, [&lt; at &gt;$soln, $n], ($n+1)..9);
    }
    return &lt; at &gt;rv;
}
my ($sum, $places) = &lt; at &gt;ARGV;
my $rv = get_digits_sum($sum, $places);
print join " ", &lt; at &gt;$_, "\n" for &lt; at &gt;$rv;

</description>
    <dc:creator>michael-pG79k+jjugCvVpAfWQikzw&lt; at &gt;public.gmane.org</dc:creator>
    <dc:date>2008-03-06T10:05:11</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2640">
    <title>Re: [QUIZ] Perl 'Medium' Quiz of the Whatever #2008-02-28 - KakuroDigit Sums</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2640</link>
    <description>
my recursive solution:
8&lt;----8&lt;
#!/usr/bin/perl

use warnings;
use strict;
use Data::Dumper;

sub get_digits_sum {
my ($sum, $num, $start) = &lt; at &gt;_;
my $max = ($sum &lt; 10 ? $sum : 9);
$start = 1 unless $start;

return [] unless $num;
return [] if $sum &lt;= 0;
return [] if $max &lt; $start;
return [[$sum]] if $num == 1;

my &lt; at &gt;result;

for my $current ($start..$max) {
push &lt; at &gt;result, map [$current, &lt; at &gt;$_], &lt; at &gt;{get_digits_sum($sum - $current, $num - 1, $current + 1)};
}

return \&lt; at &gt;result;
}

die ("run with sum and number of cell's") 
unless &lt; at &gt;ARGV == 2;
print Dumper(get_digits_sum(&lt; at &gt;ARGV));
8&lt;----8&lt;


</description>
    <dc:creator>Premysl Anydot Hruby</dc:creator>
    <dc:date>2008-03-03T17:25:03</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2639">
    <title>Re: [QUIZ] Perl 'Medium' Quiz of the Whatever #2008-02-28 - Kakuro Digit Sums</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2639</link>
    <description>
Here is my solution, which is recursive:

&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
use strict;
use warnings;

use Test::More tests =&gt; 5;

my $max_digit = 9;
my $min_digit = 1;

sub _digits_sum_from
{
    my ($start, $sum, $num_places) = &lt; at &gt;_;

    if ($num_places == 1)
    {
        if (($sum &gt;= $start) &amp;&amp; ($sum &lt;= $max_digit))
        {
            return [[$sum]];
        }
        else
        {
            return [];
        }
    }

    my &lt; at &gt;results;
    FIRST_LOOP:
    foreach my $first ($start .. $max_digit)
    {
        if ($sum-$first &lt;= 0)
        {
            last FIRST_LOOP;
        }
        push &lt; at &gt;results, 
            (map 
                { [$first,&lt; at &gt;$_] }
                &lt; at &gt;{_digits_sum_from($first+1, $sum-$first, $num_places-1)}
            );
    }
    return \&lt; at &gt;results;
}

sub get_digits_sum
{
    my ($sum, $num_places) = &lt; at &gt;_;

    return _digits_sum_from($min_digit, $sum, $num_places);
}

# TEST
is_deeply(get_digits_sum(3,2), [[1,2]], "3 over 2");

# TEST
is_deeply(get_digits_sum(7,3), [[</description>
    <dc:creator>Shlomi Fish</dc:creator>
    <dc:date>2008-03-03T15:04:36</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2638">
    <title>Re: [QUIZ] Perl 'Hard' Quiz of the Whatever #2008-12-28 - Symmetric Sokoban</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2638</link>
    <description>
Oops, and I found a bug in that logic. It's not just an optimization;
some kind of state cache is necessary to avoid just pushing the same
block back and forth forever. However, the cache currently ignores the
position of the player.

THAT is an optimization; given these two boards:

  A) #######   B) #######
     #     #      #     #
     # $ $ #      # $   #
     #     ###    # $   ###
     #     ..#    #     ..#
     #########    #########

There are multiple sets of pushes that will get you from A to B, and
no reason to try more than one set that gets you to the same result.
No matter where the player is once you've entered state B, the
possible future moves from there are all the same.

HOWEVER, if you take blocking into account:

  C) #####     D) #####
     #   #        #   #
     # #$#        # #$#
     # # ###      # # ###
     # $&lt; at &gt;..#      #&lt; at &gt;$ ..#
     #######      #######
    
States C and D are NOT equivalent -- one is solvable, and one isn't!
So if you ignore the position of the player entirely</description>
    <dc:creator>Ron Isaacson</dc:creator>
    <dc:date>2008-01-06T04:17:12</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2637">
    <title>Re: [QUIZ] Perl 'Hard' Quiz of the Whatever #2008-12-28 - Symmetric Sokoban</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2637</link>
    <description>[NB: Sorry if anyone is getting multiple copies of this. The mail
server seems to keep rejecting my mail due to attachment content type,
so the program is now included in the message.]

Jurgen Pletinckx wrote:

Same here, on both counts. :-) I just finished mine, and haven't
looked at either of the two posted solutions yet, so I'm not sure how
they compare.

My general approach is pretty simple:

  - Find all valid pushes from the current spot
  - For each push:
      - Do it
      - Recurse
      - If the puzzle is solved, exit
      - Undo it

The puzzle is always stored and used as a list of lists, with
$puzzle-&gt;[$row]-&gt;[$col] containing the actual ASCII character, and
it's never converted into any other representation. Nor is it ever
rotated or transformed in any other way (other than making moves &amp;
then reversing them).

The "find all valid pushes" piece was easier than I originally made it
out to be. I eventually settled on a non-recursive version of the
"flood fill" algorithm to radiate outward from t</description>
    <dc:creator>Ron Isaacson</dc:creator>
    <dc:date>2008-01-06T02:47:10</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2636">
    <title>Re: [QUIZ] Perl 'Hard' Quiz of the Whatever #2008-12-28 - Symmetric Sokoban</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2636</link>
    <description>
Hi all!

OK, my complete solution to the QOTW can be found here:

http://www.shlomifish.org/Files/files/code/perl/qotw/Shlomif-Sokoban-Solver-0.01.tar.gz

It includes some tests (though, not for the solving algorithm itself), a 
module and some tests.

My scheme was:

1. Store the board as a vector of 2-bits, and the states as 2 bits (locations 
of the boxes and the space accessible to the player). vec() was used for the 
bit-fiddling.

2. Make use of the symmetry by only storing and looking up the least-valued 
rotated board. This makes it unsuitable for general Sokoban solutions, at 
least until I adapt the code to detect a possible symmetry.

3. Use a BFS search to find the solution, and a BFS search to find the 
accessible places for a player to go.

------------------

There's still room for many optimisations and many dead ends are not detected 
soon enough.

The program runs in just under two minutes on my Mandriva Cooker system on a 
P4-2.4GHz machine.

I'm including here the code of my main module </description>
    <dc:creator>Shlomi Fish</dc:creator>
    <dc:date>2008-01-04T17:13:16</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2635">
    <title>RE: [QUIZ] Perl 'Hard' Quiz of the Whatever #2008-12-28 - Symmetric Sokoban</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2635</link>
    <description>Shlomi Fish &lt;mailto:shlomif-ik1l9ssToec+JF/nGntIXQ&lt; at &gt;public.gmane.org&gt; mailed on 28 December 2007
12:31:

| IMPORTANT: Please do not post solutions, hints, or other spoilers
| until at least 60 hours after the date of this message.  Thanks.
| 
| I was told the "What does this code do?" quizzes were not as good as a
new
| programming task, so here's a more traditional QOTW that I came up
with. In
| this quiz you'll try to solve the following Sokoban (
| http://en.wikipedia.org/wiki/Sokoban ) puzzle using Perl:
| 
| {{{{{{{{{{{{{{
|   ####
|   #  #
|   #  ####
| ###$.$  #
| #  .&lt; at &gt;.  #
| #  $.$###
| ####  #
|    #  #
|    ####
| }}}}}}}}}}}}}}


Well past the spoiler line now ...

(I do prefer these tasks to "WDTCD?" quizzes. *And* I 
had some tuits over the holidays. Anyone else out there?)

I've tried not to be too clever. 

* Standard breadth-first search, no heuristics

* tree is stored in a hash, as child =&gt; parent pairs

* sparse tree (I only record the fastest way to get to a state)

* the text representati</description>
    <dc:creator>Jurgen Pletinckx</dc:creator>
    <dc:date>2008-01-04T14:44:15</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2634">
    <title>[QUIZ] Perl 'Hard' Quiz of the Whatever #2008-12-28 - Symmetric Sokoban</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2634</link>
    <description>IMPORTANT: Please do not post solutions, hints, or other spoilers
until at least 60 hours after the date of this message.  Thanks.

I was told the "What does this code do?" quizzes were not as good as a new 
programming task, so here's a more traditional QOTW that I came up with. In 
this quiz you'll try to solve the following Sokoban ( 
http://en.wikipedia.org/wiki/Sokoban ) puzzle using Perl:

{{{{{{{{{{{{{{
  ####
  #  #
  #  ####
###$.$  #
#  .&lt; at &gt;.  #
#  $.$###
####  #
   #  #
   ####
}}}}}}}}}}}}}}

If you're not familiar with the notation, then "#" are walls, "$" are the 
initial positions of the boxes to be moved, "." are the destinations and "&lt; at &gt;" 
is the initial position of the player.

This level is the Microban level No. 142 in the levels collection of KSokoban. 
You may want to solve it yourself before using Perl to do so. You can load it 
into a Sokoban clone by saving it into a file and then using the "load" 
command.

Good luck and happy new year!

Regards,

Shlomi Fish

-------------------------</description>
    <dc:creator>Shlomi Fish</dc:creator>
    <dc:date>2007-12-28T11:31:02</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2633">
    <title>[QUIZ] Perl 'What does this code do?' Quiz</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2633</link>
    <description>Hi all!

Here's another "What does this code do?" Quiz. I obfuscated the names of the 
variable names to prevent hinting their purpose, but the code itself is 
not obfuscated. You have to guess what the "m2()" function does.

Good luck!

Please post spoilers as response to this post with "SPOILER".

Regards,

Shlomi Fish

&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
use strict;
use warnings;

sub m2
{
    my $c = shift;

    my $d = sub {
        my $e = shift;
        return +(ref($e) eq "ARRAY") ? $e-&gt;[1] : $e;
    };

    my $f = sub {
        my $e = shift;
        return +(ref($e) eq "ARRAY") ? $e-&gt;[0] : 1;
    };
    
    my $g;

    $g = sub {
        my ($h, $i, $j) = &lt; at &gt;_;

        if (($h == &lt; at &gt;$c) &amp;&amp; ($j == 0))
        {
            return ();
        }
        elsif ($j == 0)
        {
            return $g-&gt;($h+1, 
                $d-&gt;($c-&gt;[$h]),
                $f-&gt;($c-&gt;[$h])
            );
        }
        else
        {
            return ($i, $g-&gt;($h, $i, $j-1));
        }
    };

    return [ $g-&gt;(0, 0, 0) ];
}

1;</description>
    <dc:creator>Shlomi Fish</dc:creator>
    <dc:date>2007-10-28T17:06:31</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2632">
    <title>Re: [QUIZ] Perl 'What does this code do?' Quiz</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2632</link>
    <description>
WALKMETH is a P6 thing (described in Apocalypse 12
http://dev.perl.org/perl6/doc/design/apo/A12.html) that generates a
list of all methods that will respond to that invocation. My answer
wasn't quite correct - the implementation of CALLALL described in A12
is the closer analog to the code provided.

The "mostly complete" bit had to do with a few missing paranoia bits
in the P5 as well as the fact that CALLALL does a take as opposed to
executing the method right away (lazy vs. immediate). Personally, I
prefer lazy evaluation as the default, but that's not really possible
in P5 without breaking encapsulation or doing crazy things like
Contextual::Return and the like that completely blow your runtime
performance.

Rob

</description>
    <dc:creator>Rob Kinyon</dc:creator>
    <dc:date>2007-07-02T04:10:31</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2631">
    <title>Re: [QUIZ] Perl 'What does this code do?' Quiz</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2631</link>
    <description>





Is this the answer?

  DB&lt;54&gt; use Crypt::Rot13

  DB&lt;55&gt;  $c = Crypt::Rot13-&gt;new

  DB&lt;56&gt; $c-&gt;charge('xbmlnfui')

  DB&lt;57&gt; x $c-&gt;rot13(25)
0  'walkmeth'

But I don't know what 'walkmeth' is.

</description>
    <dc:creator>Greg Matheson</dc:creator>
    <dc:date>2007-07-01T15:08:35</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2630">
    <title>Re: SPOILER: 'What does this code do?' Quiz</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2630</link>
    <description>
That's right.


Well, the thing is that it is very unlikely, I will create a different glob 
with the name "$mn", which will be different than a subroutine. But point 
taken.


If it returns anything except an array ref, then I'd like to know about it. So 
I can assume that the contract of the function will be that, and that the 
functions of those names will be dedicated for them.

As for the origin: this code is originally based on a concept that Damian 
Conway introduced in Class::Std ( http://search.cpan.org/dist/Class-Std/ ) - 
the "CUMULATIVE" methods. I believe I read about it in his Perl Best 
Practices book.

I later implemented this feature in a somewhat different way in Test::Run 
(without making use of any of Damian's original Class::Std code), and this 
code here is based on the Test::Run code.

Regards,

Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish      shlomif-ik1l9ssToec+JF/nGntIXQ&lt; at &gt;public.gmane.org
Homepage:        http://www.shlomifish.org/</description>
    <dc:creator>Shlomi Fish</dc:creator>
    <dc:date>2007-07-01T12:49:11</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2629">
    <title>Re: [QUIZ] Perl 'What does this code do?' Quiz</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2629</link>
    <description>
What is XBMLNFUI?

I don't get it.

Regards,

Shlomi Fish


---------------------------------------------------------------------
Shlomi Fish      shlomif-ik1l9ssToec+JF/nGntIXQ&lt; at &gt;public.gmane.org
Homepage:        http://www.shlomifish.org/

If it's not in my E-mail it doesn't happen. And if my E-mail is saying
one thing, and everything else says something else - E-mail will conquer.
    -- An Israeli Linuxer

</description>
    <dc:creator>Shlomi Fish</dc:creator>
    <dc:date>2007-07-01T12:37:09</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2628">
    <title>Re: SPOILER: 'What does this code do?' Quiz</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2628</link>
    <description>
Yeah, yeah, yeah, exercise for the reader, etc, etc :-)


See, the answer was within you all the time ;-)
</description>
    <dc:creator>Peter Scott</dc:creator>
    <dc:date>2007-06-27T21:29:26</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2627">
    <title>Re: SPOILER: 'What does this code do?' Quiz</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2627</link>
    <description>
Good catch, but of course you wouldn't want to actually do that...
what if $m-&gt;($self) is very expensive, or has side effects? There's
also a race condition: how can you be sure that an arrayref return
from the first invocation of $m-&gt;($self) guarantees an arrayref return
(whether or not the same data) from the second invocation?

  my $result = $m-&gt;($self);
  push &lt; at &gt;r, &lt; at &gt;$result if (ref $result eq 'ARRAY');

--
Ron Isaacson
Morgan Stanley
ron.isaacson-/PgpppG8B+R7qynMiXIxWgC/G2K4zDHf&lt; at &gt;public.gmane.org / (212) 762-1950

</description>
    <dc:creator>Ron Isaacson</dc:creator>
    <dc:date>2007-06-27T20:42:59</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2626">
    <title>Re: [QUIZ] Perl 'What does this code do?' Quiz</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2626</link>
    <description>
Nice. An mostly complete implementation of XBMLNFUI*  in P5.

Rob

* 13x simpler than rot13 ...

</description>
    <dc:creator>Rob Kinyon</dc:creator>
    <dc:date>2007-06-27T20:22:14</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2625">
    <title>SPOILER: 'What does this code do?' Quiz</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2625</link>
    <description>
$object_or_class-&gt;z( { mn =&gt; 'funcname' } ) will return a reference to 
an array of all the list-context results of calling the 'funcname' 
method in the class of $object_or_class and its ancestors in parental 
order, assuming that each such method returns an arrayref, and that the 
above code is present in or inherited by the class of $object_or_class.

However, it checks to see only if the glob 'funcname' is defined, not 
whether there is a subroutine of that name.  It will generate a warning 
if another slot in the glob is used instead.  I would rewrite the **** 
line above as

         my $m = *{$i . "::$mn"}{CODE};

and to be on the safe side, rewrite the %%%% line as

             push &lt; at &gt;r, &lt; at &gt;{ ref $m-&gt;($self) eq 'ARRAY' ? $m-&gt;($self) : [] };

</description>
    <dc:creator>Peter Scott</dc:creator>
    <dc:date>2007-06-27T20:14:06</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2624">
    <title>[QUIZ] Perl 'What does this code do?' Quiz</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2624</link>
    <description>Hi all!

Here's another "What does this code do?" Quiz. I obfuscated the names of the 
variable names to provide hinting on their purpose, but the code itself is 
not obfuscated. You have to guess what the "z()" function does.

Good luck!

Please post spoilers as response to this post with "SPOILER".

Regards,

Shlomi Fish

&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
use strict;
use warnings;

use List::MoreUtils (qw(uniq));

our %_t = ();

sub t
{
    my $c = shift;

    if (exists($_t{$c}))
    {
        return $_t{$c};
    }

    no strict 'refs';

    my &lt; at &gt;h = $c;
    my &lt; at &gt;d = &lt; at &gt;{$c. '::ISA'};

    while (my $p = shift(&lt; at &gt;d))
    {
        push &lt; at &gt;h, $p;
        push &lt; at &gt;d, &lt; at &gt;{$p. '::ISA'};
    }

    my &lt; at &gt;u = uniq(&lt; at &gt;h);

    return $_t{$c} =
        [
            sort
            {
                  $a-&gt;isa($b) ? -1
                : $b-&gt;isa($a) ? +1
                :               0 
            }
            &lt; at &gt;u
        ];
}

sub z
{
    my ($self, $args) = &lt; at &gt;_;

    my $mn = $args-&gt;{mn};

    my $c = ((ref($self) eq "") ? $self : ref($</description>
    <dc:creator>Shlomi Fish</dc:creator>
    <dc:date>2007-06-27T19:05:53</dc:date>
  </item>
  <textinput about="http://search.gmane.org/?group=$group=gmane.comp.lang.perl.qotw.discuss">
    <title>Search Engine</title>
    <description>Search the mailing list at Gmane</description>
    <name>query</name>
    <link>http://search.gmane.org/?group=$group=gmane.comp.lang.perl.qotw.discuss</link>
  </textinput>
</rdf:RDF>
