#!/usr/bin/perl # http://perlmonks.org/?node_id=1211497 use strict; use warnings; sub up { my ($x, $y) = split /-/, $_[0]; $x && $y and up( $x - 1 . '-' . ($y - 1), @_ ); $x and up( $x - 1 . "-$y", @_ ); $x || $y or print "@_\n"; } up( '3-1' );