#!/usr/bin/perl use warnings; use strict; sub agent_generator{ #generates agents with template data my $stringset = shift; #arrayreference my @newstringset; foreach (@{$stringset}){ push @newstringset, 0; } my $looped = join "", @newstringset; while (1){ my $pos = 0; $newstringset[$pos]++; while (($pos <= $#{$stringset}) && ($newstringset[$pos] > $stringset->[$pos])) { $newstringset[$pos] = 0; $pos++; $newstringset[$pos]++; } print @newstringset,"\n"; ((pop @newstringset)&&(return @newstringset)) if ((join "", @newstringset)=~/$looped/);#if reached 0s again. } #count lowest digit up one. if digit is to high, #reset and go up one digit and count it up one. if that one #is to high go up one digit and count it up else return #to lowest digit. } my @array = qw(4 4 4 1 6 2 1 1 2 1 1 9); my @a2 = qw(3 3); my @new = agent_generator(\@a2); print @new,"\n";