%indentation = ( '0' => 1, '2' => 3, '4' => 2, ); #### # Yes, sometimes I write code in ways to make sure _I_ # remember what I was doing when I come back to it later. sub gcf { my ( $i, $j ) = sort { $b <=> $a} @_; return( abs( $j ) ) if ( $i == 0 ); return( abs( $i ) ) if ( $j == 0 ); return( abs( gcf( $j, $i % $j ) ); } my $common_indent_factor = 1; my @data = sort { $b <=> $a } keys %indentation; while ( scalar @data ) { my $f_1 = shift @data; my $f_2 = shift @data; my $f_temp = $common_indentation_factor = gcf( $f_1, $f_2 ); push @data, $f_temp; }