#!/usr/bin/perl
 
# Will generate all combinations of the given characters for a given length
 
sub gen;
 
@chars = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); # This should hold all the characters you want in the mix.
$length = 6; # Set the length you want here.
 
my @word = ((0) x $length - 1); # Create null array of the length we need
 
&gen(0); # Start generating at the first character.
 
sub gen {
	foreach $char (@chars) {
		@word[$_[0]] = $char;
		if($_[0] < $length - 1) {
			&gen($_[0] + 1);
		} else {
			print @word; print "\n";
		}
	}
}