App::War - turn one big decision into many small decisions


    use App::War;
    my $war = App::War->new;
    $war->items(qw/ this that the-other that-too /);
    print $war->report;


How do you go about ranking a number of items? One way to do it is to compare the objects two at a time until a clear winner can be established.

This module does just that, using a topological sort to establish a unique ordering of all the "combatants" in the "war".

This module is modeled loosely after, a crowdsourced web application for determining the cutest kitten in the universe.



Constructs a new war object.


Starts the war.


Uses the content of $self->items to initialize a graph containing only vertices, one per item.


Returns the current state of the war graph as a multiline string.


Returns the graph object that stores the user choices.


Get/set the items to be ranked. It's a bad idea to modify this once the war has started.


Starts the process of uniquely ordering the graph vertices. This method calls method tsort_not_unique until it returns false, i.e. we have a unique topo sort.


This method returns a true value (more on this later) if the graph currently lacks a unique topo sort. If the graph has a unique sort, the "war" is over, and results should be reported.

If the graph lacks a unique topological sort, this method returns an arrayref containing a pair of vertices that have an ambiguous ordering. From

    If a topological sort has the property that all pairs of consecutive vertices in the sorted order are connected by edges, then these edges form a directed Hamiltonian path in the DAG. If a Hamiltonian path exists, the topological sort order is unique; no other order respects the edges of the path.

This property of the topological sort is used to ensure that we have a unique ordering of the "combatants" in our "war".


Handles user interaction choosing one of two alternatives. Arguments $index1 and $index2 are indexes into the internal array of items to be ranked, and indicate the two items that need to have their rank disambiguated.


John Trammell, <>


Please report any bugs or feature requests to bug-app-war at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc App::War

Your operating system may also have installed a manual page for this module; it would likely be available via the command

    man war

You can also look for information at:


Copyright 2009 John Trammell, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.